In my code I'm using configparser:
from configparser import ConfigParser
And I'm using pip freeze to generate my requirements.txt
pip freeze > requirements.txt
And for configparser it's writing
configparser==3.3.0.post2
But that fails when I do a pip install -r requirements.txt from within the docker container via a docker build:
docker build -t denzel .
Downloading/unpacking configparser==3.3.0.post2 (from -r /home/denzel/requirements.txt (line 2))
Could not find a version that satisfies the requirement configparser==3.3.0.post2 (from -r /home/denzel/requirements.txt (line 2)) (from versions: 3.2.0r1, 3.2.0r2, 3.2.0r3, 3.3.0r1, 3.3.0r2, 3.5.0b1, 3.5.0b2)
Cleaning up...
No distributions matching the version for configparser==3.3.0.post2 (from -r /home/denzel/requirements.txt (line 2))
But this works locally via pip install:
pip install -r requirements.txt
Requirement already satisfied (use --upgrade to upgrade): aniso8601==1.1.0 in ./env/lib/python2.7/site-packages (from -r requirements.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): configparser==3.3.0.post2 in ./env/lib/python2.7/site-packages (from -r requirements.txt (line 2))
....
....
NOTE: I fixed this by removing the version and just using configparser, no version. Still wanted to post my question to get the reason why it's failing.
Following will work with docker
app.py
from configparser import ConfigParser
config = ConfigParser()
config.read('app.conf')
_var = config.get(‘Section’, 'Status')
print (_var)
requirements.txt
configparser
Following will work locally
app.py
import ConfigParser
config = ConfigParser.ConfigParser()
config.read('app.conf')
_var = config.get(‘Section’, 'Status')
print (_var)
Related
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
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
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.
First rule is work every time with virtual enviroment "virtual env documentation"
I know it's hard work, but you can backup that 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
I have a major problem preventing me from setting up my developer environment using pip 7.1.2 and Python 3.5 in a virtual environment. First of all, I can't even update pip, let alone install any packages, as this is always the same error:
(venv) ➜ venv git:(master) ✗ pip install --upgrade pip
Collecting pip
Could not find a version that satisfies the requirement pip (from versions: )
No matching distribution found for pip
Let's try a requirements.txt file that contains the following:
pytz
django==1.11.4
The error produced is the same:
(venv) ➜ venv git:(master) ✗ pip install -r requirements.txt
Collecting pytz (from -r requirements.txt (line 1))
Could not find a version that satisfies the requirement pytz (from -r requirements.txt (line 1)) (from versions: )
No matching distribution found for pytz (from -r requirements.txt (line 1))
Maybe, it's because a version number is missing? Let's add the latest correct package version, 2019.2, and run the install from requirements.txt one more time.
(venv) ➜ venv git:(master) ✗ pip install -r requirements.txt
Collecting pytz==2019.2 (from -r requirements.txt (line 1))
Could not find a version that satisfies the requirement pytz==2019.2 (from -r deploy/requirements.txt (line 1)) (from versions: )
No matching distribution found for pytz==2019.2 (from -r requirements.txt (line 1))
Let's try django, with or without version numbers.
(venv) ➜ venv git:(master) ✗ pip install django
Collecting django
Could not find a version that satisfies the requirement django (from versions: )
No matching distribution found for django
It appears that pip under version 9.0.2 on OSX is incompatible with SSL certificates issued by the new pip servers. To updgrade pip manually from this situation, you need to run the following:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
I can't recall how I installed mod_wsgi-express, but I'm almost certain that I used pip.
I've got this line in my requirements.txt file:
mod_wsgi-express==4.5.15
Collecting mod_wsgi-express==4.5.15 (from -r /usr/src/app/requirements.txt (line 16))
Could not find a version that satisfies the requirement mod_wsgi-express==4.5.15 (from -r /usr/src/app/requirements.txt (line 16)) (from versions: )
No matching distribution found for mod_wsgi-express==4.5.15 (from -r /usr/src/app/requirements.txt (line 16))
You are using pip version 9.0.0, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Is the naming different here? Or am I just not seeing that package?
$ pip list | grep mod
mod-wsgi (4.5.15)
mod-wsgi-httpd (2.4.23.2)
In requirements.txt: mod_wsgi==4.5.15
The package information can be found on PyPi at:
https://pypi.python.org/pypi/mod_wsgi
I am trying to download deendencies from artifactory in the fllowing way
requirements.txt
--index-url https://artifactory.company.com/artifactory/api/pypi/pypi-repos
django-rss-plugin==0.0.9
nltk==3.0.1
And then running
pip install -r requirements.txt
This results in the follwoing error
Collecting django-rss-plugin==0.0.9 (from -r requirements.txt (line 3))
Could not find a version that satisfies the requirement django-rss-plugin==0.0.9 (from -r requirements.txt (line 3)) (from versions: )
No matching distribution found for django-rss-plugin==0.0.9 (from -r requirements.txt (line 3))
This is true for any dependency. I am using the version 9.0.1 for pip.Also https://artifactory.company.com/artifactory/api/pypi/pypi-repos is the virtual repository that proxies the remote repo
You can specify the index in your command and remove from the file:
pip install -r requirement.txt -i https://artifactory.company.com/artifactory/api/pypi/pypi-repos
File:
django-rss-plugin==0.0.9
nltk==3.0.1
EDIT
The error is from the index URL itself.
I created and uploaded a package callled pdfminer.six on PyPi
It installs correctly through "pip install pdfminer.six" on my PC (Windows)
and passes tests on travis-ci
Since I need this package for my other project (Goulib), I added "pdfminer.six" it to its requirements.txt, but Travis.ci fails importing this package ) :
Downloading/unpacking pdfminer.six (from -r requirements.txt (line 7))
Could not find any downloads that satisfy the requirement pdfminer.six
(from -r requirements.txt (line 7)) Some insecure and unverifiable
files were ignored (use --allow-unverified pdfminer.six to allow).
Cleaning up... No distributions at all found for pdfminer.six (from -r
requirements.txt (line 7))
Tried to add --allow-unverified and version number ==20140915 in all possible ways, no change ...
What should I do to make pdfminer.six "secure and verifiable" on Travis-ci ?