How to use requirements.txt to install all dependencies in a python project

后端 未结 5 1033
滥情空心
滥情空心 2020-12-02 08:46

I am new to python. Recently I got a project written by python and it requires some installation. I run below command to install but got an error.

# pip inst         


        
相关标签:
5条回答
  • 2020-12-02 09:11
    python -m pip install -r requirements.txt
    

    Referece: How to install packages using pip according to the requirements.txt file from a local directory?

    0 讨论(0)
  • 2020-12-02 09:16

    (Taken from my comment)

    pip won't handle system level dependencies. You'll have to apt-get install libfreetype6-dev before continuing. (It even says so right in your output. Try skimming over it for such errors next time, usually build outputs are very detailed)

    0 讨论(0)
  • 2020-12-02 09:23

    If you are using Linux OS:

    1. Remove matplotlib==1.3.1 from requirements.txt
    2. Try to install with sudo apt-get install python-matplotlib
    3. Run pip install -r requirements.txt (Python 2), or pip3 install -r requirements.txt (Python 3)
    4. pip freeze > requirements.txt

    If you are using Windows OS:

    1. python -m pip install -U pip setuptools
    2. python -m pip install matplotlib
    0 讨论(0)
  • 2020-12-02 09:31

    Python 3:

    pip3 install -r requirements.txt
    

    Python 2:

    pip install -r requirements.txt
    

    To get all the dependencies for the virtual environment or for the whole system:

    pip freeze
    

    To push all the dependencies to the requirements.txt (Linux):

    pip freeze > requirements.txt
    
    0 讨论(0)
  • 2020-12-02 09:33

    pip install -r requirements.txt for python 2.x

    pip3 install -r requirements.txt for python 3.x (in case multiple versions are installed)

    0 讨论(0)
提交回复
热议问题