Reputation: 2776
I am currently trying to install a requirements and it is telling me that it is not found when I try and comment them out it happens for others.
I just deployed a Ubuntu 18.04
server. Made the virtual env by the following command python3 -m venv --system-site-packages env
but every single time I try and run pip install -r requirements.txt
it fails with
Collecting apparmor==2.12 (from -r requirements.txt (line 1))
Could not find a version that satisfies the requirement apparmor==2.12 (from -r requirements.txt (line 1)) (from versions: )
No matching distribution found for apparmor==2.12 (from -r requirements.txt (line 1))
if I try and install say pip install apparmor
it tells me
Collecting apparmor
Could not find a version that satisfies the requirement apparmor (from versions: )
No matching distribution found for apparmor
But then if I comment out apparmor it tells me this
Collecting apturl==0.5.2 (from -r requirements.txt (line 2))
Could not find a version that satisfies the requirement apturl==0.5.2 (from -r requirements.txt (line 2)) (from versions: )
No matching distribution found for apturl==0.5.2 (from -r requirements.txt (line 2))
and it goes on for others randomly. The requirements was made on my local which is also ubuntu 18
so unsure why this works on local but not on a new deploy.
I have also made sure that it's the newest version of pip
Upvotes: 8
Views: 26391
Reputation: 368
The solution is ignoring the builtin libraries that already exist and can't be downloaded by pypi if you need to change them you will need to change python version .so the workaround i used is running each line of requirements file separately so that unfound error do not stop all process of installs. here is the code .if you need any question just ask i m pro i can help you
import subprocess #Builtin python librarie that will wil used to run commands
with open('requirements.txt') as f: # Opening requirements file
t=f.read().split("\n") # Spliting the contents of requirements to array of strings
for e in t: #Creating loop ot iter over each line (element of array)
subprocess.run("python -m pip install "+e) #Running the process of python install libraries
Upvotes: 0
Reputation: 532
This is a common problem when you don't use virtual enviroment for work with python, so your requirements.txt
lists all the packages pythons of your system or OS, when you must have only the packages from your project. In some moment you update your requirements.txt
with pip freeze > requirements.txt
, without a virtual environment and you updated the requirements.txt
with all python packages in your OS and from your project, and maybe uploaded to a repository. So when you want to run in another computer and install all packages you got this kind of error...
Python is installed by default in ubuntu, you must consider this and in other system too.
requirements.txt
and clean it. Then try to run your program without any package (a clean install) and when errors occurs from missing packages you add it and update with pip freeze > requirements.txt
Upvotes: 9
Reputation: 66461
apparmor
and apturl
are Ubuntu packages, you can safely ignore them if your code doesn't use their code; just remove them from requirements.txt
. If your code depends on them, ensure they are installed via apt
:
apt install -y apparmor apturl && pip install -r requirements.txt
Upvotes: 13