Python Django requirements.txt - python

I have a requirements.txt file containing all my dependencies but it is not processed correctly :
After a pip install -r requirements.txt, I get the following pip freeze :
argparse==1.2.1
wsgiref==0.1.2
But when I do a pip install of :
numpy==1.6.2
Django==1.4.2
django-tastypie==0.9.14
pyes==0.19.1
And then run my pip install -r requirements.txt . Then it works.
Here is what my requirements.txt contains :
numpy==1.6.2
Django==1.4.2
django-tastypie==0.9.14
urllib3==1.5
pyes==0.19.1
BeautifulSoup==3.2.1
MySQL-python==1.2.3
IMAPClient==0.9.1
Jinja2==2.6
Pillow==2.0.0
amqp==1.0.9
anyjson==0.3.3
billiard==2.7.3.22
celery==3.0.16
django-celery==3.0.11
django-compressor==1.3
django-concurrency
django-extensions==1.1.1
https://codeload.github.com/toastdriven/django-haystack/zip/master#egg=django-haystack
django-model-utils==1.2.0
django-multiforloop==0.2.1
django-social-auth==0.7.22
html5lib==0.95
httplib2==0.8
kombu==2.5.7
logilab-astng==0.24.2
logilab-common==0.59.0
oauth2==1.5.211
ordereddict==1.1
pycrypto==2.6
pylint==0.27.0
python-dateutil==1.5
python-openid==2.2.5
pytz==2013b
six==1.3.0
unittest2==0.5.1
wsgiref==0.1.2
xlrd==0.9.0
xmltodict==0.4.6
django-storages>=1.1.8
boto==2.8.0
lxml==3.1.0
pyelasticsearch==0.4.1
django-tastypie-elasticsearch==0.1.0
Would anyone have a solution ?

I tried this out and the problem is with django-tastypie-elasticsearch. There is a known issue, whereby installation with pip fails if Django hasn't been installed yet. Here is the issue report:
https://github.com/llonchj/django-tastypie-elasticsearch/issues/1
Looks like django-tastypie-elastic has only two contributors, so you're probably on your own. The good news is that it wasn't your fault!

On mac:
To get your already installed dependencies
pip3 freeze > requirements.txt
from: Automatically create requirements.txt
Then if you want to install them, and you are using a virtual environment
pip3 install -r requirements.txt
from:
How can I install packages using pip according to the requirements.txt file from a local directory?
If you want to update them
I just know how to do it with pip-review.
https://pypi.org/project/pip-review/#description
pip3 install pip-review or pip install pip-review
then pip-review --local --auto
from:
How to upgrade all Python packages with pip

The "https://codeload.github.com/toastdriven/django-haystack/zip/master#egg=django-haystack" line is not a valid pip requirement. It should read "-e git+https://codeload.github.com/toastdriven/django-haystack/zip/master#egg=django-haystack"

Related

How to add git source in requirements.txt

I would like to install a certain package from a private git repository. This is possible using pip install git+<REPO_LINK>. However, I would like to pip install -r requirements.txt all of my packages at the same time without having to specify which one comes from Pypi and private repo.
I have tried adding a configuration in ~/.config/pip/pip.conf
[global]
find-links =
git+<REPO_LINK>
but this happened when running pip install -r requirements.txt:
ERROR: Could not find a version that satisfies the requirement my-package==0.1
Thanks in advance.
I have found a solution for it at this doc.
pip install git+<REPO_LINK>#egg=<PACKAGE_NAME>
When I run pip freeze, the package I have just installed is printed like this:
git+<REPO_LINK>#egg=<PACKAGE_NAME>
Add it to your requirements.txt so pip install -r requirements.txt install this specific package so as public ones from Pypi.
:)

Python update package version in requirements.txt

I have a requirement.txt file with the list of python package to install. One of the packages is psycopg2==2.6.2 I need to update this package to psycopg2==2.7. I tried to install by pip3 install psycopg2 But it doesn't affect requirement.txt file. Can you please point me in the right direction?
Notice that running pip3 install psycopg2 doesn't respect the requirements.txt file. To upgrade this package you need to use -U option:
pip3 install -U psycopg2
which is a shorthand for:
pip3 install --upgrade psycopg2
After that, you can update your requirements.txt with the following command:
pip freeze > requirements.txt
If you're looking for a solution to automatically update the requirements.txt file after you upgrade package/packages, you can use pip-upgrader.
Installation:
pip install pip-upgrader
Usage:
pip-upgrade
The above command auto-discovers the requirements file and prompts for selecting upgrades. You can also specify a path to the requirements file or/and specify a package to upgrade:
pip-upgrade /path/to/requirements.txt -p psycopg2
As you've discovered, pip doesn't update the requirements file. So the workflow you'd likely want to use is:
Update the version of psycopg2 in your requirements file from 2.6.2 to 2.7
Run pip install with the upgrade flag
pip3 install -U -r requirements.txt
If you're familiar with tools like npm that do update the version in the catalog file, you may be interested in using pipenv, which manages your dependencies and the virtual environment for you, much like npm does.
If you don't know the latest version of your package, then use pip to figure it out:
$ pip list --outdated | grep psycopg2
psycopg2 (2.7.3.2) - Latest: 2.7.4 [wheel]
you can try:
pip install --upgrade --force-reinstall -r requirements.txt
You can also ignore installed package and install the new one :
pip install --ignore-installed -r requirements.txt

What does " -r " do in pip install -r requirements.txt

I looked up how to install multiple packages from a requirements document using pip. The answers were mostly:
pip install -r requirements.txt
What does the -r do though? I can't find an answer for this and it isn't listed when I run pip help.
Instead of pip --help, look into pip install --help:
-r, --requirement Install from the given requirements
file. This option can be used multiple
times.
Also see these documentation paragraphs:
pip install
Requirements Files.
-r will search for requirement file.
pip install --help
will help you !!
May, 2022 Update:
If you run this command below without "-r":
pip install requirements.txt
You will get this error below:
ERROR: Could not find a version that satisfies the requirement requirements.txt (from versions: none)
HINT: You are attempting to install a package literally named "requirements.txt" (which cannot exist). Consider using the '-r' flag to install the packages listed in requirements.txt
ERROR: No matching distribution found for requirements.txt
Because "pip" tries to install the package "requirements.txt" instead of installing the packages listed in "requirements.txt". Of cource, the package "requirements.txt" doesn't exist in PyPI while for example, the packages "django" and "pillow" exist in PyPI:
pip install django
pip install pillow
So, to install the packages listed in "requirements.txt", you must need "-r";
pip install -r requirements.txt
You can check what "-r" means by running the command below:
pip install --help
-r, --requirement Install from the given requirements file. This option can be used multiple times.
In your case pip install -r requirements.txt will install the libraries listed in your requirements.txt file.
pip install requirements.txt
Above statement looks for a python package named requirements.txt. No such package exists. Your intention is that pip install opens the txt and reads the packages from there. The -r allows pip install to open requirements.txt and install the packages inside of it instead.

python pip trouble installing from requirements.txt

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 all found for somepackage Storing debug log for failure in /root/.pip/pip.log
Could not find any downloads that satisfy the requirement somepackage
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-RjqjFW/psycopg2
I know these packages are installed on the main system, but its like they won't work on the venv. How do you all get around this problem? It's been a long day and I just don't understand what the problem is, especially because they work on my local system, they work on the main python install on my remote system, but not in the venv for some crazy reason. Any ideas?
Here is the requirements, I thought it was alittle intense for django, but thats what pip freeze > requirements.txt gave me
Babel==1.3
Django==1.7.1
Fabric==1.10.1
Flask==0.10.1
Flask-Babel==0.9
Flask-Login==0.2.11
Flask-Mail==0.9.1
Flask-OpenID==1.2.4
Flask-SQLAlchemy==2.0
Flask-WTF==0.10.3
Flask-WhooshAlchemy==0.56
Jinja2==2.7.3
MarkupSafe==0.23
PAM==0.4.2
Pillow==2.3.0
Pygments==1.6
Scrapy==0.24.4
Sphinx==1.2.2
Tempita==0.5.2
WTForms==2.0.1
Werkzeug==0.9.6
Whoosh==2.6.0
adium-theme-ubuntu==0.3.4
apt-xapian-index==0.45
argparse==1.2.1
backports.ssl-match-hostname==3.4.0.2
blinker==1.3
boto==2.20.1
bottle==0.12.7
certifi==14.05.14
chardet==2.0.1
colorama==0.2.5
command-not-found==0.3
coverage==3.7.1
cssselect==0.9.1
debtagshw==0.1
decorator==3.4.0
defer==1.0.6
dirspec==13.10
docutils==0.11
duplicity==0.6.23
ecdsa==0.11
flipflop==1.0
guess-language==0.2
guppy==0.1.9
html5lib==0.999
httplib2==0.8
ipython==2.3.1
itsdangerous==0.24
lockfile==0.8
lxml==3.3.3
nose==1.3.4
numpy==1.8.2
oauthlib==0.6.1
oneconf==0.3.7
paramiko==1.15.2
pbr==0.10.7
pexpect==3.1
piston-mini-client==0.7.5
psycopg2==2.5.4
pyOpenSSL==0.13
pyasn1==0.1.7
pycrypto==2.6.1
pycups==1.9.66
pycurl==7.19.3
pygame==1.9.1release
pygobject==3.12.0
pyserial==2.6
pysmbc==1.0.14.1
python-apt==0.9.3.5ubuntu1
python-debian==0.1.21-nmu2ubuntu2
python-openid==2.2.5
pytz==2014.10
pyxdg==0.25
queuelib==1.2.2
reportlab==3.0
requests==2.2.1
roman==2.0.0
sessioninstaller==0.0.0
simplegeneric==0.8.1
six==1.5.2
software-center-aptd-plugins==0.0.0
speaklater==1.3
sqlalchemy-migrate==0.9.2
sqlparse==0.1.14
system-service==0.1.6
tornado==4.0.2
unity-lens-photos==1.0
urllib3==1.7.1
virtualenv==1.11.6
w3lib==1.10.0
wsgiref==0.1.2
wxPython==2.8.12.1
wxPython-common==2.8.12.1
xdiagnose==3.6.3build2
z3c.xmlhttp==0.5.1
zope.interface==4.0.5
zope.publisher==4.0.0a4
zope.traversing==4.0.0
zope.viewlet==4.0.0a1
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.
try pip install -r requirements.txt
It worked for me
I see a few problems:
Your requirements.txt is for the base system Python, not any virtual environment. Django does not have any external dependencies.
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
sudo pip install -r requirements.txt or pip install -r requirements.txt worked for me
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.
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
You have the same problem that I stack with, So the solution is easy:
You must check the file path the text takes from it like in a blue circle.
Run code below:
cd C:\Users\yk406.anaconda\yolov7
Note: path directory is an example paste the path that your environment works in
when the first step is done the second one is done by installing file text like in a green circle.
Run code below:
pip install -r requirements.txt

pip - installation of sub-dependencies overrides other packages on requirements.txt

my requirements file is like that :
https://github.com/sontek/pyramid_webassets/archive/38b0b9f9f4e36dc22b3a5c10eabf4d9228d97740.zip#egg=pyramid_webassets-0.0
https://github.com/miracle2k/webassets/archive/334d55c6bcfd091cb2d984777daf943acde0d364.zip#egg=webassets-0.8.dev
when running pip install -r requirements.txt I want it to install the specific version of pyramid_webassets, and then the specific webassets version (0.8.dev)
the problem is that pyramid_webassets have the webassets as sub-dependency, and it installs the latest of this package.
so the output of pip freeze is
Chameleon==2.14
Mako==0.9.1
MarkupSafe==0.18
PasteDeploy==1.5.2
WebOb==1.3.1
argparse==1.2.1
pyramid==1.4.5
pyramid-webassets==0.0
repoze.lru==0.6
translationstring==1.1
venusian==1.0a8
webassets==0.9
wsgiref==0.1.2
zope.deprecation==4.1.0
zope.interface==4.0.5
you might notice that webassets version is the latest (0.9) though I specified the version I want (0.8.dev).
I tried to reorder the list, adding the --upgrade flag- nothing helped.
any idea how can I install it and still having the required version of webassets?
Thanks.
soultion:
I found this commend useful:
cat requirements.txt | xargs -L1 pip install
that will install one by one the packages orderly
but we should add --upgrade for the last package so it'll upgrade it.
use pip install option to not install package dependencies
$ pip install --no-deps -r requirements.txt
Doing a pip freeze afterwards
gottfried#sascha-Latitude-XT2:~/venv$ bin/pip freeze
argparse==1.2.1
pyramid-webassets==0.0
webassets==0.8.dev
wsgiref==0.1.2
References
pip cookbook - Ensuring repeatability
What happens when you move webassets higher then pyramid_webassets on the list?

Categories