I am trying to deploy my Django app on GCP using google appengine.
First I deployed the app after testing on localhost by following this documentation by Google appengine.
deployed the app using gcloud app deploy
But there is some issue and the server is not running showing the error as 502 Bad Gateway
Then I checked the logs and then realized that I forgot to upload the requiremts.txt file.
the uploaded file and tried to deploy the app again.
But got an error as
ERROR: Cannot install -r requirements.txt (line 19), -r requirements.txt (line 21), -r requirements.txt (line 27) and grpcio==1.48.1 because these package versions have conflicting dependencies.
Here is some dependency conflict between modules Gcloud suggested a documentation https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts to solve this but I'm not getting it actually how to solve the conflict of modules in requirements.txt
Here is the requirements.txt file
APScheduler==3.6.3
asgiref==3.5.2
backports.zoneinfo==0.2.1
beautifulsoup4==4.11.1
cachetools==4.2.2
certifi==2022.6.15
charset-normalizer==2.1.1
dill==0.3.5.1
Django==4.0.6
django-environ==0.9.0
django-social-share==2.3.0
environ==1.0
google==3.0.0
google-api-core==2.10.0
google-auth==2.11.0
google-cloud-secret-manager==2.12.4
google-cloud-speech==2.15.1
googleapis-common-protos==1.56.4
grpc-google-iam-v1==0.12.4
grpcio==1.48.1
grpcio-status==1.48.1
idna==3.3
Pillow==9.2.0
proto-plus==1.22.1
protobuf==4.21.5
psycopg2==2.9.3
pulumi==3.39.3
pyasn1==0.4.8
pyasn1-modules==0.2.8
pytz==2022.2.1
pytz-deprecation-shim==0.1.0.post0
PyYAML==6.0
requests==2.28.1
rsa==4.9
semver==2.13.0
six==1.16.0
soupsieve==2.3.2.post1
sqlparse==0.4.2
tornado==6.2
tzdata==2022.1
tzlocal==4.2
urllib3==1.26.12
And an error log
Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9] Cloud build 7ac526d7-15d5-45f6-afe7-727b4216f79d status: FAILURE
.... This could take a while.
INFO: pip is looking at multiple versions of google-api-core to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of google to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of environ to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of django-social-share to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of django-environ to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of django to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of dill to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of charset-normalizer to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of certifi to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of cachetools to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of beautifulsoup4 to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of backports-zoneinfo to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of <Python from Requires-Python> to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of asgiref to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of apscheduler to determine which version is compatible with other requirements. This could take a while.
ERROR: Cannot install -r requirements.txt (line 19), -r requirements.txt (line 21), -r requirements.txt (line 27) and grpcio==1.48.1 because these package versions have conflicting dependencies.
The conflict is caused by:
The user requested grpcio==1.48.1
grpc-google-iam-v1 0.12.4 depends on grpcio<2.0.0dev and >=1.0.0
grpcio-status 1.48.1 depends on grpcio>=1.48.1
pulumi 3.39.3 depends on grpcio==1.47
To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
Please help me to solve this error
Thanks
I would use something like poetry to manage your dependencies while you work on your app. It will actually help you not to run into conflicts and solve most of them for you automatically.
Then when you are ready to deploy your app you can do:
poetry export -f requirements.txt --output requirements.txt
And poetry will generate a requirements.txt file that you can upload to GCP
I tried running git push heroku master in cmd but got the following error:
ERROR: Could not find a version that satisfies the requirement get (from -r /tmp/build_8801ce40/requirements.txt (line 2)) (from versions: none)
ERROR: No matching distribution found for get (from -r /tmp/build_8801ce40/requirements.txt (line 2))
remote: ! Push rejected, failed to compile Python app.
I have listed in my requirements.txt as below:
Flask==0.11.1
get
gunicorn==19.6.0
post
requests
wikipedia
line-bot-sdk
pandas==0.20.3
googletrans
What is the problem, and how can I fix it?
Your requirements.txt should only contain modules that you need to install. get and post almost certainly don't belong here.
If you are doing something like
from requests import get
you'll need requests in your file. But you don't need get—it comes with requests. That's what the from requests part means.
Try editing your requirements.txt to something more like this:
Flask==0.11.1
gunicorn==19.6.0
requests
wikipedia
line-bot-sdk
pandas==0.20.3
googletrans
Then commit and redeploy.
A good way to make sure that your requirements.txt contains what it should is to use it in development, too. Add new dependencies directly to that file and then pip install -r requirements.txt. In this case, you would have caught the problem earlier.
I currently have a pip mirror installed on an internal server (this is an offline network). The url to access it is http://pypi.python.org/simple. I have created a configuration file at ~/.pip/pip.conf with the following contents:
[global]
index-url = http://pypi.python.org/simple
trusted-host = pypi.python.org
I can successfully install packages that don't have nested dependencies, such as by performing pip3 install requests. I get the output of it installing requests, idna, chardet, certifi, and urllib3 successfully. However, when I need to install something from pip that has nested dependencies, such as via pip3 install driller, I get the following output:
Collecting driller
Downloading driller-1.0.tar.gz
Collecting angr (from driller)
Downloading angr-8.19.2.4.tar.gz (758kB)
100% | | 768kB 75.7MB/s
Complete output from command python setup.py egg_info:
Download error on https://pypi.python.org/simple/pyvex/: [Errno 111] Connection refused -- Some packages may not be found!
...
It's weird to me that the error occurs as a result of attempting to reach https://pypi.python.org/simple as opposed to my local mirror that I specified via index-url at http://pypi.python.org. Additionally, if I perform pip3 install pyvex it installs just fine. Am I missing how to propagate my index-url/trusted host through the pip install command when there are nested dependencies?
I had the exact same question and got the answer in this thread on StackOverflow.
Here is the solution
Find the Python directories on your system and add the following two lines to the distutils.cfg in the folder distutils. If the config file does not exist yet, create it.
[easy_install]
index_url = blablabla
on my Home Office I use Ubuntu 12.04. Now I try to configure python with netcdf4. I installed a lot of packages like numpy, pandas, matplotlib, hdf5, cython, h5py,... When I try to install netcdf4 I got the error message:
Collecting netcdf
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages /urllib3/util/ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading netcdf-0.2.1.tar.gz (16.5MB)
100% |████████████████████████████████| 16.5MB 42kB/s
Requirement already satisfied (use --upgrade to upgrade): numpy==1.8.0 in /usr/local/lib/python2.7/dist-packages/numpy-1.8.0-py2.7-linux-x86_64.egg (from netcdf)
Collecting h5py==2.3.1 (from netcdf)
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading h5py-2.3.1.tar.gz (1.1MB)
100% |████████████████████████████████| 1.1MB 223kB/s
Collecting netCDF4==1.1.0 (from netcdf)
Downloading netCDF4-1.1.0.tar.gz (562kB)
100% |████████████████████████████████| 563kB 340kB/s
Complete output from command python setup.py egg_info:
HDF5_DIR environment variable not set, checking some standard locations ..
checking /home/elly ...
checking /usr/local ...
HDF5 found in /usr/local
NETCDF4_DIR environment variable not set, checking standard locations..
checking /home/elly ...
checking /usr/local ...
checking /sw ...
checking /opt ...
checking /opt/local ...
checking /usr ...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-q2Vs7i/netCDF4/setup.py", line 232, in <module>
raise ValueError('did not find netCDF version 4 headers')
ValueError: did not find netCDF version 4 headers
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-q2Vs7i/netCDF4/
I searched different pages with similar issues and tried install-instructions:
sudo apt-get install python-dev
sudo apt-get install libevent-dev
sudo apt-get indtall python-all-dev
Do anyone have another idea to fix this? Thanks!
I was trying to do the same and I finally found the full list :
python3 -m pip install -U pip
pip3 install -upgrade setuptools
pip3 install netCDF4
it should work now :) it worked for me (centos8, python3)
I'm installing several Python packages in Ubuntu 12.04 using the following requirements.txt file:
numpy>=1.8.2,<2.0.0
matplotlib>=1.3.1,<2.0.0
scipy>=0.14.0,<1.0.0
astroML>=0.2,<1.0
scikit-learn>=0.14.1,<1.0.0
rpy2>=2.4.3,<3.0.0
and these two commands:
$ pip install --download=/tmp -r requirements.txt
$ pip install --user --no-index --find-links=/tmp -r requirements.txt
(the first one downloads the packages and the second one installs them).
The process is frequently stopped with the error:
Could not find a version that satisfies the requirement <package> (from matplotlib<2.0.0,>=1.3.1->-r requirements.txt (line 2)) (from versions: )
No matching distribution found for <package> (from matplotlib<2.0.0,>=1.3.1->-r requirements.txt (line 2))
which I fix manually with:
pip install --user <package>
and then run the second pip install command again.
But that only works for that particular package. When I run the second pip install command again, the process is stopped now complaining about another required package and I need to repeat the process again, ie: install the new required package manually (with the command above) and then run the second pip install command.
So far I've had to manually install six, pytz, nose, and now it's complaining about needing mock.
Is there a way to tell pip to automatically install all needed dependencies so I don't have to do it manually one by one?
Add: This only happens in Ubuntu 12.04 BTW. In Ubuntu 14.04 the pip install commands applied on the requirements.txt file work without issues.
Although it doesn't really answers this specific question. Others got the same error message with this mistake.
For those who like me initial forgot the -r: Use pip install -r requirements.txt the -r is essential for the command.
The original answer:
https://stackoverflow.com/a/42876654/10093070
I had installed python3 but my python in /usr/bin/python was still the old 2.7 version
This worked (<pkg> was pyserial in my case):
python3 -m pip install <pkg>
This approach (having all dependencies in a directory and not downloading from an index) only works when the directory contains all packages. The directory should therefore contain all dependencies but also all packages that those dependencies depend on (e.g., six, pytz etc).
You should therefore manually include these in requirements.txt (so that the first step downloads them explicitly) or you should install all packages using PyPI and then pip freeze > requirements.txt to store the list of all packages needed.
Just a reminder to whom google this error and come here.
Let's say I get this error:
$ python3 example.py
Traceback (most recent call last):
File "example.py", line 7, in <module>
import aalib
ModuleNotFoundError: No module named 'aalib'
Since it mentions aalib, I was thought to try aalib:
$ python3.8 -m pip install aalib
ERROR: Could not find a version that satisfies the requirement aalib (from versions: none)
ERROR: No matching distribution found for aalib
But it actually wrong package name, ensure pip search(service disabled at the time of writing), or google, or search on pypi site to get the accurate package name:
Then install successfully:
$ python3.8 -m pip install python-aalib
Collecting python-aalib
Downloading python-aalib-0.3.2.tar.gz (14 kB)
...
As pip --help stated:
$ python3.8 -m pip --help
...
-v, --verbose Give more output. Option is additive, and can be used up to 3 times.
To have a systematic way to figure out the root causes instead of rely on luck, you can append -vvv option of pip command to see details, e.g.:
$ python3.8 -u -m pip install aalib -vvv
User install by explicit request
Created temporary directory: /tmp/pip-ephem-wheel-cache-b3ghm9eb
Created temporary directory: /tmp/pip-req-tracker-ygwnj94r
Initialized build tracking at /tmp/pip-req-tracker-ygwnj94r
Created build tracker: /tmp/pip-req-tracker-ygwnj94r
Entered build tracker: /tmp/pip-req-tracker-ygwnj94r
Created temporary directory: /tmp/pip-install-jfurrdbb
1 location(s) to search for versions of aalib:
* https://pypi.org/simple/aalib/
Fetching project page and analyzing links: https://pypi.org/simple/aalib/
Getting page https://pypi.org/simple/aalib/
Found index url https://pypi.org/simple
Getting credentials from keyring for https://pypi.org/simple
Getting credentials from keyring for pypi.org
Looking up "https://pypi.org/simple/aalib/" in the cache
Request header has "max_age" as 0, cache bypassed
Starting new HTTPS connection (1): pypi.org:443
https://pypi.org:443 "GET /simple/aalib/ HTTP/1.1" 404 13
[hole] Status code 404 not in (200, 203, 300, 301)
Could not fetch URL https://pypi.org/simple/aalib/: 404 Client Error: Not Found for url: https://pypi.org/simple/aalib/ - skipping
Given no hashes to check 0 links for project 'aalib': discarding no candidates
ERROR: Could not find a version that satisfies the requirement aalib (from versions: none)
Cleaning up...
Removed build tracker: '/tmp/pip-req-tracker-ygwnj94r'
ERROR: No matching distribution found for aalib
Exception information:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 186, in _main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 357, in run
resolver.resolve(requirement_set)
File "/usr/lib/python3/dist-packages/pip/_internal/legacy_resolve.py", line 177, in resolve
discovered_reqs.extend(self._resolve_one(requirement_set, req))
File "/usr/lib/python3/dist-packages/pip/_internal/legacy_resolve.py", line 333, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/usr/lib/python3/dist-packages/pip/_internal/legacy_resolve.py", line 281, in _get_abstract_dist_for
req.populate_link(self.finder, upgrade_allowed, require_hashes)
File "/usr/lib/python3/dist-packages/pip/_internal/req/req_install.py", line 249, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/usr/lib/python3/dist-packages/pip/_internal/index/package_finder.py", line 926, in find_requirement
raise DistributionNotFound(
pip._internal.exceptions.DistributionNotFound: No matching distribution found for aalib
From above log, there is pretty obvious the URL https://pypi.org/simple/aalib/ 404 not found. Then you can guess the possible reasons which cause that 404, i.e. wrong package name. Another thing is I can modify relevant python files of pip modules to further debug with above log. To edit .whl file, you can use wheel command to unpack and pack.
After 2 hours of searching, I found a way to fix it with just one line of command. You need to know the version of the package (Just search up PACKAGE version).
Command:
python3 -m pip install --pre --upgrade PACKAGE==VERSION.VERSION.VERSION
Below command worked for me -
python -m pip install flask
Not always, but in some cases the package already exists. For example - getpass. It is not listed by "pip list" but it can be imported and used:
If I try to pip install getpass I get the following error:
"Could not find a version that satisfies the requirement getpass"
Try installing flask through the powershell using the following command.
pip install --isolated Flask
This will allow installation to avoide environment variables and user configuration.
If you facing this issue at the workplace. This might be the solution for you.
pip install -U <package_name> --user --proxy=<your proxy>
Pip install from pypi.org.
pip install -U -i https://pypi.org/simple package
One possible error, pip package requires python intepreter which you are not using.
I ran into the same problem, it occurred only when I ran commands from my Docker image (or Dockerfile). Finally many hours later I managed to solve it by updating my python intepreter. Pointed out that my pip-package required python>=3,7 but my Docker image was using python 3.6.
Tip: To check out if you have similar problem, just check pip package requirements and your python version. Private pip package intepreter requirements are wrote down inside setup.py or setup.cfg. Public pip packages are usuially hosted in pypi.org where you can just check intepreter requirements with your browser. To check your python intepreter version just write for example python --version or python3 --version in your console
General problem description
As other answers point out there can also be other requirements that you are not satisfying and that is why pip can not found suitable package version for you. All the requirements are wrote down in pip package documentation and can be easily readed from https://pypi.org/project/graphene-django/your-package
I got this error while installing awscli on Windows 10 in anaconda (python 3.7).
While troubleshooting, I went to the answer https://stackoverflow.com/a/49991357/6862405 and then to https://stackoverflow.com/a/54582701/6862405. Finally found that I need to install the libraries PyOpenSSL, cryptography, enum34, idna and ipaddress. After installing these (using simply pip install command), I was able to install awscli.
When I lost my internet connection, I had this error.
Since it's a pretty annoying problem that may stuck beginners for a long period of time, here I write a complete guild.
if you are running pip install PACKAGE or python -m pip install PACKAGE, and a no matching version found error reported, here's how to solve the problem.
search your package on browser, for example my package is pycypto, here I search pycypto pypi
find your package, open the link on pypi, click download file
open a python shell, import any of your installed package, for example, I have installed Pillow before.
>>> import PIL
>>> PIL.__path__
['/Applications/MAMP/htdocs/canvas/src/zzd/env/lib/python3.7/site-packages/PIL']
PACKAGE.__path__ function will gives you the side packages path where all packages should go into.
PLUS:
if you have no idea what packages you installed before, run pip list to get a list of installed packages.
after we obtain the path, open a shell, cd to the path
cd /Applications/MAMP/htdocs/canvas/src/zzd/env/lib/python3.7/site-packages/
open
unzip the downloaded file, drag it into site-packages.
cd into the downloaded directory, and run setup.py to install
cd pycrypto-2.6.1
python setup.py install
Then you should be able to import and use the package in python.
Same error in slightly different circumstances, on MacOs. Apparently setuptools versions past 45 can expose some issues and this command got me past it:
pip3 install setuptools==45
If the package is local, don't miss the relative path.
E.g.
pip install ./<pkg>
finally worked in my case, while
pip install <pkg>
yielded:
ERROR: Could not find a version that satisfies the requirement <pkg> (from versions: none)
ERROR: No matching distribution found for <pkg>
I had a problem installing pandas-1.4.3, and the problem was my python patch version. pandas-1.4.3 required python version 3.8.13 and did not work with 3.8.9:
python install -r requirements.txt # or pip install pandas==1.4.3
# -> Could not find a version that satisfies...
conda activate my_project # creates a virtual env for a new python version
conda install python=3.8.13 # installing the new python version
python --version # displays 3.8.13
pip install -r python/requirements.txt
# -> pandas installed as expected
Search in google if you find some other version of that package available
use that for example
I was getting errors using the glob so I used glob2 instead