Pip3 gives "No matching distribution found for ..." error - python-3.x

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.

Related

How do I update PIP repository in order to make new versions of python packages visible?

I'm setting up a RHEL8 (8.7) based Docker container, with Python 3.8.13 installed (installed python3-pip, python3.6, python 3.8 and 3.9 too). I have tried to install some Python libraries using requirements.txt:
RUN pip3 install -r requirements.txt
The txt file is recognized, some of the requirements are found and installed, but some of them are exiting with the failure code: 1
For example, I want to install joblib 1.2.0 and numpy 1.23.2, so my requirements.txt file has the following entries too:
joblib == 1.2.0
numpy == 1.23.2
But the build exits with the following as soon as it reaches the "joblib" line:
Collecting joblib==1.2.0 (from -r requirements.txt (line1))
Could not find a version that satisfies the requirement joblib==1.2.0 (from -r requirements.txt (line1)) (from versions: 0.3.2d.dev, ..*omitting a massive list of versions*.. 1.1.0, 1.1.1)
No matching distribution found for joblib==1.2.0 (from -r requirements.txt (line1))
error building image: error building stage: failed to execute command: waiting for process to exit: exit status 1
I have tried to install EPEL and probably install Python 3.10 or 3.11 but did not succeed, probably not supported by RHEL8.
I have gone through the following checks advised for cases when pip does not find the correct version:
pip install -r requirements.txt command is indeed running with the -r option.
version of pip is pip3, matching the installed Python3
name of the module is not misspelled, correct
the listed modules are not built-in modules (they indeed have to be installed separately)
package does support the version of Python:
Joblib 1.2.0 supported Python versions are 3.7+ (as stated, 3.8 and 3.9 is installed too)
Numpy 1.23.2 supported Python versions are 3.8-3.11
So these should be visible for pip3 installer - yet they are not, Joblib max offered version is 1.1.1...
Is there a workaround or solution for this?

Installing or updating a package using the pip in Python

If I accidentally run any of the following commands to install or update a package using pip in Python 3.x twice, will it install or update that package twice on the machine?
pip install <package_name>
pip install --upgrade <package_name>
After updating a package twice, it says that:
Requirement already satisfied: appnope in ./.pyenv/versions/3.11.0/lib/python3.11/site-packages (from ipykernel) (0.1.3)"
Does this mean I already updated or installed the package?
Yes, it means you have already installed or upgraded.
The first command installs the package. Because you have not specified a package version with something like pip install package-name==1.0.0, pip will install the package with the latest version.
The second command attempts to upgrade the same package. Because it is installed with the latest version, there is nothing to upgrade. pip will not reinstall packages unless you ask it to.
pip install --upgrade --force-reinstall <package-name>
pip will also attempt to install dependencies for your packages that may be required for the package you requested.
Requirement already satisfied: appnope in ./.pyenv/versions/3.11.0/lib/python3.11/site-packages (from ipykernel) (0.1.3)"

How to solve `ResolutionImpossible` error in python when downloading packages?

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)

unable to locate pip packages using asdf in VSC

I have just installed a fresh install of BigSur and Python (using asdf) when installing pip packages they seem to end up in:
./.asdf/installs/python/3.9.2/lib/python3.9/site-packages
when typing which flake8 for example I get flake8 not found but when I go to install it again pip install flake8 I get the following:
> which flake8
flake8 not found
~
> pip install flake8
Requirement already satisfied: flake8 in ./.asdf/installs/python/3.9.2/lib/python3.9/site-packages (3.8.4)
Requirement already satisfied: pycodestyle<2.7.0,>=2.6.0a1 in ./.asdf/installs/python/3.9.2/lib/python3.9/site-packages (from flake8) (2.6.0)
Requirement already satisfied: mccabe<0.7.0,>=0.6.0 in ./.asdf/installs/python/3.9.2/lib/python3.9/site-packages (from flake8) (0.6.1)
Requirement already satisfied: pyflakes<2.3.0,>=2.2.0 in ./.asdf/installs/python/3.9.2/lib/python3.9/site-packages (from flake8) (2.2.0)
I have just tried to use requests which I installed like pip install requests and I also got not found when using which but I manage to use the package in VSC ok.
I am using flake8 and Black and I need to give VSC their paths. I have used
./.asdf/installs/python/3.9.2/lib/python3.9/site-packages/<package name>
but VSC doesn't seem to pip it up. I am using the latest verisons.
> python -V
Python 3.9.2
~
> pip -V
pip 21.0.1 from /Users/paul/.asdf/installs/python/3.9.2/lib/python3.9/site-packages/pip (python 3.9)
this might help too:
~
> which python
/Users/paul/.asdf/shims/python
~
> which pip
/Users/paul/.asdf/shims/pip
Any idea how I can get which to display the correct paths so I can get my listing and formatting working ok?
This fixed it... https://til.hashrocket.com/posts/ques11vrjs-get-pip-installed-executables-into-the-asdf-path
asdf reshim python
I would be curious why I have to do this...if anyone could answer

How can an old setuptools be upgraded if the old version encounters an error when trying to upgrade itself?

I appear to have encountered the following error by using an older version of setuptools with Python 3:
https://github.com/pypa/setuptools/issues/885
How can I actually advance to a newer version to escape this error? It's a bit of a catch 22.
python -m pip install --upgrade pip setuptools wheel
Download the source distribution, unpack it, and install it like this:
$ wget https://pypi.python.org/packages/e0/02/2b14188e06ddf61e5b462e216b15d893e8472fca28b1b0c5d9272ad7e87c/setuptools-38.5.2.zip
$ unzip setuptools-38.5.2.zip
$ cd setuptools-38.5.2
$ python3 bootstrap.py
Note: neither pip nor wheel are necessary to install setuptools.

Resources