2017-01-04 15 views
13

私はpythonの初心者です。最近、Pythonで書かれたプロジェクトがあり、インストールが必要です。私は以下のコマンドを実行してインストールしますが、エラーが発生しました。requirements.txtを使用してpythonプロジェクトにすべての依存関係をインストールする方法

# pip install requirements.txt 
Collecting requirements.txt 
    Could not find a version that satisfies the requirement requirements.txt (from versions:) 
No matching distribution found for requirements.txt 

私はGoogleで検索し、このリンクhttp://stackoverflow.com/questions/28167987/python-pip-trouble-installing-from-requirements-txtを見つけましたが、私はかなりその記事ではどのような解決策を理解していません。以下は

私requirements.txtファイルです:

# cat requirements.txt 
ordereddict==1.1 
argparse==1.2.1 
python-dateutil==2.2 
matplotlib==1.3.1 
nose==1.3.0 
numpy==1.8.0 
pymongo==3.3.0 
psutil>=2.0 

このPythonプロジェクトに必要なすべての依存関係をインストールする簡単な方法はありますか?以下は

EDIT1

pip3 install -r requirements.txtから出力されます。

# pip3 install -r requirements.txt 
Requirement already satisfied: ordereddict==1.1 in /usr/local/lib/python3.5/dist-packages (from -r requirements.txt (line 1)) 
Collecting argparse==1.2.1 (from -r requirements.txt (line 2)) 
    Using cached argparse-1.2.1.tar.gz 
Collecting python-dateutil==2.2 (from -r requirements.txt (line 3)) 
    Using cached python-dateutil-2.2.tar.gz 
Collecting matplotlib==1.3.1 (from -r requirements.txt (line 4)) 
    Using cached matplotlib-1.3.1.tar.gz 
    Complete output from command python setup.py egg_info: 
    ============================================================================ 
    Edit setup.cfg to change the build options 

    BUILDING MATPLOTLIB 
       matplotlib: yes [1.3.1] 
        python: yes [3.5.2 (default, Nov 17 2016, 17:05:23) [GCC 
          5.4.0 20160609]] 
        platform: yes [linux] 

    REQUIRED DEPENDENCIES AND EXTENSIONS 
        numpy: yes [version 1.11.3] 
        dateutil: yes [using dateutil version 2.6.0] 
        tornado: yes [tornado was not found. It is required for the 
          WebAgg backend. pip/easy_install may attempt to 
          install it after matplotlib.] 
       pyparsing: yes [using pyparsing version 2.1.10] 
        pycxx: yes [Official versions of PyCXX are not compatible 
          with Python 3.x. Using local copy] 
        libagg: yes [pkg-config information for 'libagg' could not 
          be found. Using local copy.] 
        freetype: no [The C/C++ header for freetype2 (ft2build.h) 
          could not be found. You may need to install the 
          development package.] 
         png: yes [pkg-config information for 'libpng' could not 
          be found. Using unknown version.] 

    OPTIONAL SUBPACKAGES 
       sample_data: yes [installing] 
        toolkits: yes [installing] 
        tests: yes [using nose version 1.3.7] 

    OPTIONAL BACKEND EXTENSIONS 
        macosx: no [Mac OS-X only] 
        qt4agg: no [PyQt4 not found] 
        gtk3agg: no [gtk3agg backend does not work on Python 3] 
       gtk3cairo: no [Requires cairo to be installed.] 
        gtkagg: no [Requires pygtk] 
        tkagg: no [TKAgg requires Tkinter.] 
        wxagg: no [requires wxPython] 
         gtk: no [Requires pygtk] 
         agg: yes [installing] 
        cairo: no [cairo not found] 
       windowing: no [Microsoft Windows only] 

    OPTIONAL LATEX DEPENDENCIES 
        dvipng: no 
       ghostscript: no 
        latex: no 
        pdftops: no 

    ============================================================================ 
          * The following required packages can not be built: 
          * freetype 

    ---------------------------------------- 
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-don4ne_2/matplotlib/ 

私はすでにlibfreetype6-devインストールされているが、PIPコマンドは、まだこの依存関係が欠落して報告します。 (私のコメントからの引用)(複数のバージョンがインストールされている場合には)python 3.xためpython 2.x

pip3 install -r requirements.txtため

# apt-get install libfreetype6-dev 
Reading package lists... Done 
Building dependency tree  
Reading state information... Done 
libfreetype6-dev is already the newest version (2.6.1-0.1ubuntu2). 
0 upgraded, 0 newly installed, 0 to remove and 4 not upgraded. 
+8

'-r requirements.txt' – MrLeeh

+0

をインストールPIPをそれでもインストールすることはできません。 –

+0

今、新しい出力を読んで考えてください。私たちを待ってはいけません。 – furas

答えて

8

を:

  1. requirements.txt
  2. から matplotlib==1.3.1を削除します
  3. sudo apt-get install python-matplotlib
  4. 実行pip install -r requirements.txt(パイソン2)、またはpip3 install -r requirements.txt(Pythonの3)
  5. pip freeze > requirements.txt
  6. にインストールしてみてください

は、Windows OSを使用している場合:私は、-rフラグを使用して出力を含めるように出力を更新しました

  1. python -m pip install -U pip setuptools
  2. python -m pip install matplotlib
+3

こんにちはNilesh、スタックオーバーフローへようこそ。将来は、あなたの答えに与えるコマンドが何をしているのかを説明してください。単にコマンドを実行するよう人々に言わないでください。 – yakatz

4

pip install -r requirements.txt

+0

私は両方を試みましたが、まだ失敗しました。私はこのコマンドの出力を掲示しました。 –

+0

私はMATPLOTLIBをインストールするために必要な依存関係 'freetype'がないと思います。依存関係をインストールし、pip install -r requirements.txtをもう一度実行してみてください。 –

+0

'pip'はシステムレベルの依存関係を処理しません。続行する前に 'apt-get install libfreetype6-dev'を実行する必要があります。 (あなたの出力にもそうだと言えますが、次回はこのようなエラーをスキミングしてみてください。通常はビルド出力は非常に詳細です) –

0

pipは、システムレベルの依存関係を処理しません。続行する前にapt-get install libfreetype6-devにする必要があります。 (それも、あなたの出力のように、右と言う通常の出力は非常に詳述されて構築し、このようなエラーのためにその上に次の時間をスキミングしてください。)あなたは、Linux OSを使用している場合は

+0

私はすでにlibfreetype6-devをインストールしています。しかしピップはまだこのエラーを報告しています。 –

+0

このバグは見ましたか? https://github.com/matplotlib/matplotlib/issues/3029/ –

関連する問題