How to solve `ResolutionImpossible` error in python when downloading packages? - python-3.x

I am getting this error when using pip to install from a requirements file.
C:\Users\keerthi\AppData\Local\Programs\Python\Python36\healthcare\Ai-Healthcare-Chatbot-master>pip install -r requirements.txt
Collecting Flask==0.12.3
Using cached Flask-0.12.3-py2.py3-none-any.whl (88 kB)
Requirement already satisfied: chatterbot==0.8.4 in c:\users\keerthi\appdata\local\programs\python\python36\lib\site-packages (from -r requirements.txt (line 5)) (0.8.4)
Requirement already satisfied: SQLAlchemy==1.1.11 in c:\users\keerthi\appdata\local\programs\python\python36\lib\site-packages (from -r requirements.txt (line 6)) (1.1.11)
Collecting gunicorn==19.10.0
Using cached gunicorn-19.10.0-py2.py3-none-any.whl (113 kB)
ERROR: Cannot install SQLAlchemy==1.1.11 and chatterbot==0.8.4 because these package versions have conflicting dependencies.
The conflict is caused by:
The user requested SQLAlchemy==1.1.11
chatterbot 0.8.4 depends on sqlalchemy<1.3 and >=1.2
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/user_guide/#fixing-conflicting-dependencies

One way that works for now is to use the legacy resolver. You can get the legacy resolver by (1) downgrading pip, or (2) using the --use-deprecated flag.
Using an older pip version
I know that pip==20.1.1 uses the old resolver, you could downgrade to that version.
pip install pip==20.1.1
Using the --use-deprecated flag
You can also use the legacy resolver with newer versions of pip with this flag (I tested this with pip==22.3.1).
pip install --use-deprecated=legacy-resolver .......
(took me forever to find this flag, btw)

Related

Is there a go-to way to install CuPy on Windows 10 right now?

I can see that the installation guide:
https://docs.cupy.dev/en/stable/install.html
is quite outdated and a note on the Github release page of v9.0.0a2:
https://github.com/cupy/cupy/releases/tag/v9.0.0a2
states that the older version supporting CUDA v11.1 did not work in the first place and all wheels have been removed from PyPi as a response. Trying to install CuPy with an updated pip, none of the wheels are back up. Is there still a version (for any CUDA version for that matter) that works on Windows then? Can I build the newer v9.0.0b1 on Windows from source maybe?
C:\Windows\system32>python -m pip install -U setuptools pip
Requirement already satisfied: setuptools in c:\users\c\appdata\local\programs\python\python38-32\lib\site-packages (51.1.2)
Requirement already satisfied: pip in c:\users\c\appdata\local\programs\python\python38-32\lib\site-packages (20.3.3)
C:\Windows\system32>pip install cupy-cuda111
ERROR: Could not find a version that satisfies the requirement cupy-cuda111
ERROR: No matching distribution found for cupy-cuda111

pip3 installs a version of dependency that violates requirement specifiers

I have the following two dependencies in my requirements.txt:
$ pip3 install elasticsearch==7.0.0 requests==2.21.0
Collecting elasticsearch==7.0.0
Using cached https://files.pythonhosted.org/packages/a8/27/d3a9ecd9f8f972d99da98672d4766b9f62ef64c323c40bb5e2557e538ea3/elasticsearch-7.0.0-py2.py3-none-any.whl
Collecting requests==2.21.0
Using cached https://files.pythonhosted.org/packages/7d/e3/20f3d364d6c8e5d2353c72a67778eb189176f08e873c9900e10c0287b84b/requests-2.21.0-py2.py3-none-any.whl
Collecting urllib3>=1.21.1 (from elasticsearch==7.0.0)
Using cached https://files.pythonhosted.org/packages/39/ec/d93dfc69617a028915df914339ef66936ea976ef24fa62940fd86ba0326e/urllib3-1.25.2-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests==2.21.0)
Using cached https://files.pythonhosted.org/packages/60/75/f692a584e85b7eaba0e03827b3d51f45f571c2e793dd731e598828d380aa/certifi-2019.3.9-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests==2.21.0)
Using cached https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl
Collecting idna<2.9,>=2.5 (from requests==2.21.0)
Using cached https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl
requests 2.21.0 has requirement urllib3<1.25,>=1.21.1, but you'll have urllib3 1.25.2 which is incompatible.
Installing collected packages: urllib3, elasticsearch, certifi, chardet, idna, requests
Successfully installed certifi-2019.3.9 chardet-3.0.4 elasticsearch-7.0.0 idna-2.8 requests-2.21.0 urllib3-1.25.2
I want to understand this warning that appeared in the above output:
requests 2.21.0 has requirement urllib3<1.25,>=1.21.1, but you'll have urllib3 1.25.2 which is incompatible.
Why did pip install urllib3 1.25.2? It does not seem to make sense. The required dependencies are:
elasticsearch==7.0.0 requires urllib3>=1.21.1 (source)
requests==2.21.0 requires urllib3>=1.21.1,<1.25 (source)
Both dependencies could have been easily satisfied by installing urllib3 1.24.3. Why did pip3 then install urllib3 1.25.2? Isn't deciding the correct version according to the available requirements one of its responsibility?
It this a bug in pip3 or is this functioning as designed?
Update on 10th of November 2020
Install beta version of pip, it will solve the dependencies correctly for you.
Or install latest stable and run pip install --use-feature=2020-resolver.
Original answer
As it is now, pip doesn’t have true dependency resolution, but instead simply uses the first specification it finds for a project.
You can add constraints.txt file with urllib3==1.24.3 and then invoke:
$ pip install -r requirements.txt -c contraints.txt
That would do the job. When updating requirements remember to update also contraints.
Alternatively you can use one of Python dependency managers:
Pipenv
Poetry
pip-tools
DepHell
See Requirements Files and Constraints Files sections in pip user guide and Managing Application Dependencies tutorial.

Error installing required modules from setuptools (matplolib)

I am developing a python library that I wish to distribute afterwards. In order to do this I am configuring setuptools. Currently I am testing all this in a fresh install of Ubuntu 18.0.4.2 after doing an update & upgrade.
The problem is that my setup.py looks like this (I defined the oldest available package):
setup(
...
install_requires=[
'setuptools>=40.0.0',
'matplotlib>=1.0.1',
'numpy>=1.3.0',
'scipy>=0.8.0',
],
...
)
and when I install my package from test.pypi I get this error with matplotlib:
Collecting LIB_TEST_NEW
Using cached https://test-files.pythonhosted.org/packages/e6/6a/d3f7569c437b70e4c048e8597977c3d42e9baa1151c0245f210cb6e529f1/LIB_TEST_NEW-0.1.2-py3-none-any.whl
Collecting matplotlib>=1.0.1 (from LIB_TEST_NEW)
Could not find a version that satisfies the requirement matplotlib>=1.0.1 (from LIB_TEST_NEW) (from versions: )
No matching distribution found for matplotlib>=1.0.1 (from LIB_TEST_NEW)
I have tried both with and without specifying the version of the modules and also defining the modules in a separate requirements.txt.
Any help would be appreciated :)
SOLUTION:
After some digging I found a solution.
"If you want to allow pip to also pull other packages from PyPI you can specify --extra-index-url to point to PyPI. This is useful when the package you’re testing has dependencies:"
Then using:
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple your-package
Solved my error. Hope it helps someone.

Unable to upgrade tensorflow to 1.3.0

My current tensorflow version is 1.2.1, and I want to upgrade it to a new version 1.3.0. I download the whl file from website and type the command in the terminal:
sudo pip install --upgrade tensorflow_gpu-1.3.0-cp27-none-linux_x86_64.whl
but it couldn't work. It gives me the following message:
Requirement already up-to-date: mock>=2.0.0 in /usr/local/lib/python2.7/dist-packages (from tensorflow-gpu==1.3.0)
Downloading/unpacking tensorflow>=1.2.0 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow-gpu==1.3.0)
Could not find any downloads that satisfy the requirement tensorflow>=1.2.0 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow-gpu==1.3.0)
Cleaning up...
No distributions at all found for tensorflow>=1.2.0 (from tensorflow-tensorboard<0.2.0,>=0.1.0->tensorflow-gpu==1.3.0)
Storing debug log for failure in /home/zxf/.pip/pip.log
Anyone knows what's wrong with?
I face the same problem. Just try upgrade CPU version which will upgrade all needed libraries. Then upgrade GPU version, everything works fine.

Pip3 gives "No matching distribution found for ..." error

I have a reqs.txt file, containing many python requirements I need to install on a second computer. The file looks like this:
alabaster==0.7.9
anaconda-client==1.6.0
anaconda-navigator==1.4.3
astroid==1.4.9
astropy==1.3
Babel==2.3.4
backports.shutil-get-terminal-size==1.0.0
beautifulsoup4==4.5.3
bitarray==0.8.1
blaze==0.10.1
...
I am using
pip3 install -r reqs.txt --requirement=reqs.txt
and I get
me#pc:~$ pip3 install -r reqs.txt --requirement=reqs.txt
Collecting alabaster==0.7.9 (from -r reqs.txt (line 1))
Using cached alabaster-0.7.9-py2.py3-none-any.whl
Collecting anaconda-client==1.6.0 (from -r reqs.txt (line 2))
Could not find a version that satisfies the requirement anaconda-client==1.6.0 (from -r reqs.txt (line 2)) (from versions: 1.1.1, 1.2.2)
No matching distribution found for anaconda-client==1.6.0 (from -r reqs.txt (line 2))
for every single package in that reqs.txt file. Any ideas?
EDIT: The reqs.txt file was created with pip freeze. Even if I remove the version numbers, they still won't install. If I , however, do a
pip3 install alabaster
it will install with no problems.
The alabaster has no problem in it's installation, however anaconda-client isn't available in 1.6.0 using pip3 probably in your original environment you have a standalone installation of Anaconda so it's version is superior. Thus making the pip3 install -r reqs.txt not work, to work you could downgrade the version to one available in pip or install the conda environment on the second computer before running your command.

Resources