python pip trouble installing from requirements.txt

前端 未结 6 2066
清酒与你
清酒与你 2020-12-13 00:12

I\'ve had great luck with pip in the past, but working at installing some stuff in a venv on is giving me some headaches. I keep getting errors like No distributions at

相关标签:
6条回答
  • 2020-12-13 00:42

    I had this problem but with a different cause - I had an old version of virtualenv. Before version 1.7 you had to specify the option --no-site-packages when you create the virtual environment to not include global packages.

    Two options to fix this, either upgrade your virtualenv:

    sudo pip install virtualenv --upgrade
    virtualenv venv
    

    Or use the old one with the no-site-packages option:

    virtualenv venv --no-site-packages
    

    That fixed my requirements.txt file.

    0 讨论(0)
  • 2020-12-13 00:45

    I see a few problems:

    1. Your requirements.txt is for the base system Python, not any virtual environment. Django does not have any external dependencies.

    2. You are using the root user to install packages in your virtual environment (or you are using sudo when you shouldn't).

    The best option is to start from scratch:

    $ virtualenv myvenv
    ...
    $ source myvenv/bin/activate
    (myvenv) $ pip install django
    ...
    (myvenv) $ pip freeze > requirements.txt
    
    0 讨论(0)
  • 2020-12-13 00:52

    Following solution has worked for me :

    (my-virtualenv) 20:42 ~/MyPf (master)$ pip freeze > requirements.txt | 
    (my-virtualenv) 20:43 ~/MyPf (master)$ pip install -r requirements.txt
    
    0 讨论(0)
  • 2020-12-13 00:55

    Had a similar issue but the above method didn't work for me. Clarified it with a rather simpler solution:

    (venv) $ pip install --upgrade -r requirements.txt

    UPDATE: This command upgrades all packages that have been explicitly listed in your requirements.txt file.

    Your requirements.txt file is just a list of pip install arguments placed in a file. They are used to hold the result from pip freeze for the purpose of achieving repeatable installations. In this case, your requirements.txt file contains a pinned version of everything that was installed when pip freeze was run.

    0 讨论(0)
  • 2020-12-13 00:57

    try pip install -r requirements.txt

    It worked for me

    0 讨论(0)
  • 2020-12-13 01:00

    sudo pip install -r requirements.txt or pip install -r requirements.txt worked for me

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