I type
sudo pip install "line_profiler"
and I get
Downloading/unpacking line-profiler
Could not find a version that satisfies the requirement line-profiler (from versions: 1.0b1, 1.0b2, 1.0b3)
Cleaning up...
No distributions matching the version for line-profiler
Storing debug log for failure in /home/milia/.pip/pip.log
When I search for line_profile using
sudo pip search "line_profiler"
I get:
django-debug-toolbar-line-profiler - A panel for django-debug-toolbar that integrates
information from line_profiler
line_profiler - Line-by-line profiler.
tracerbullet - A line-by-line profiler that doesn't suck.
Somehow the underscore gets turned to "-". How can I bypass that?
The problem is not in the fact that pip converts _ into the - to meet the package naming requirements, but the thing is: the package is in beta state, there is no stable package versions. In other words, there are only beta package version links available on the package PyPI page. As you see, pip sees it:
Could not find a version that satisfies the requirement line-profiler (from versions: 1.0b1, 1.0b2, 1.0b3)
According to the Pre-release Versions documentation page:
Starting with v1.4, pip will only install stable versions as specified
by PEP426 by default. If a version cannot be parsed as a compliant
PEP426 version then it is assumed to be a pre-release.
Pass --pre argument to the pip install:
--pre
Include pre-release and development versions. By default, pip only finds stable versions.
sudo pip install --pre line_profiler
Or, install a specific version:
sudo pip install line_profiler==1.0b3
I installed miniconda and run these:
$ conda install -c anaconda line_profiler
Related
I recently switched to Apple Silicon and am trying to now install all packages in a Python project in the requirements.txt. However, since the architecture is different, I have trouble satisfying all requirements, specifically sub-dependencies.
requirements.txt
ethnicolr==0.8.1
# and many more, but this one is causing issues
Installing it with pip install -r requirements.txt yields
ERROR: Could not find a version that satisfies the requirement
tensorflow==2.5.2 (from ethnicolr) (from versions: none)
TensorFlow 2.4.0 is available for this setup, and it should work with ethnicolr. So how do I override the version of the sub-dependency in requirements.txt?
I am using Mambaforge for virtual environments btw. because it is recommended to run a PyData Stack on Apple M1
A way to workaround that is to explicitly set your dependencies and run pip install with a --no-deps parameter.
After setting my requirements.txt as:
ethnicolr==0.8.1
# and many more, but this one is causing issues
tensorflow==2.5.0 # You set this to whatever version you want to
I ran:
> pip install --no-deps -r requirements.txt
Collecting ethnicolr==0.8.1
Using cached ethnicolr-0.8.1-py2.py3-none-any.whl (36.1 MB)
Collecting tensorflow==2.5.0
Using cached tensorflow-2.5.0-cp39-cp39-manylinux2010_x86_64.whl (454.4 MB)
Installing collected packages: tensorflow, ethnicolr
Successfully installed ethnicolr-0.8.1 tensorflow-2.5.0
This implies a clear issue: You'll have to know beforehand which deps your packages use. To easily find out those, you can use pip-tools
You should install a version of ethnicolr that doesn't have that specific requirement for the tensorflow version. pip install ethnicolr==0.2.0could work.
In conda I can have the following environment.yml:
# name of the environment
name: rust_env
# channels from which the dependencies will be sourced. The order defines the priority.
channels:
- anaconda
- conda-forge
- defaults
# conda dependencies
dependencies:
# name==version==hash?
- anyio=3.3.4=py39hcbf5309_1
# ...
- pip:
# regular pip dependency
# name==version
- jupyter-contrib-core==0.3.3
# dependency sourced from git repo
# name#git+link
- nbconvert#git+https://github.com/JohnScience/nbconvert.git#0b84bb8c3d94cfa229d12c1069e426d907e98d05
Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow
This message is shown when I try to pip install. I have tried it with python 3.7 when it didn't work. I also tried it with 3.6 and I still tensorflow can't install it.
Try using Christoph Gohlke's packages: https://www.lfd.uci.edu/~gohlke/pythonlibs/#tensorflow
Download the package for Python 3.6, then use pip install on the package:
pip install tensorflow‑1.9.0‑cp36‑cp36m‑win_amd64.whl
Note that you will need the NumPy + MKL packages and the Protobuf packages that can be downloaded from Christoph Gohlke's website as well.
NumPy + MKL: https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
Protobuf: https://www.lfd.uci.edu/~gohlke/pythonlibs/#protobuf
Make sure you choose the Python 3.6 version. You can determine this by looking at the numbers after the cp in the filename (i.e. cp36).... so what you'll actually need to do is download the three wheels, then install them in the following order:
pip install numpy‑1.16.3+mkl‑cp36‑cp36m‑win_amd64.whl
pip install protobuf‑3.7.1‑cp36‑cp36m‑win_amd64.whl
pip install tensorflow‑1.9.0‑cp36‑cp36m‑win_amd64.whl
Note: I'm assuming you're using a 64-bit version of Windows which is the default type for many Windows installations.
Try to install it using the following command
python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.13.1-py3-none-any.whl
So I've installed python via homebrow. When I do brew info python I get this:
python: stable 3.6.5 (bottled), devel 3.7.0rc1, HEAD
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python/3.6.5_1 (5,107 files, 103.0MB) *
Poured from bottle on 2018-06-18 at 10:15:49
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/python.rb
==> Dependencies
Build: pkg-config ✔, sphinx-doc ✘
Required: gdbm ✔, openssl ✔, readline ✔, sqlite ✔, xz ✔
Optional: tcl-tk ✘
==> Options
--with-tcl-tk
Use Homebrew's Tk instead of macOS Tk (has optional Cocoa and threads support)
--devel
Install development version 3.7.0rc1
--HEAD
Install HEAD version
==> Caveats
Python has been installed as
/usr/local/bin/python3
Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
/usr/local/opt/python/libexec/bin
If you need Homebrew's Python 2.7 run
brew install python#2
Pip, setuptools, and wheel have been installed. To update them run
pip3 install --upgrade pip setuptools wheel
You can install Python packages with
pip3 install <package>
They will install into the site-package directory
/usr/local/lib/python3.6/site-packages
See: https://docs.brew.sh/Homebrew-and-Python
I'm ultimately trying to do pip3 install numpy but when I do that, I get this message:
-bash: pip3: command not found
pip install numpy seems to point to the Apple default 2.7 python version:
Requirement already satisfied: numpy in /Library/Python/2.7/site-packages (1.14.5)
So the problem seems to be in my .bash_profile as which python gives /usr/bin/python.
Here's what that looks like:
export PATH=/usr/local/bin:$PATH
export PATH=/usr/local/Cellar/python/3.6.5_1/bin:$PATH
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
export PATH=$PATH:/Users/thammond/Library/Android/sdk/platform-tools
###########
export PATH=/usr/local/Cellar/postgresql\#9.6/9.6.6/bin:$PATH
###########
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
I confirmed that /usr/local/ was listed at the top and also tried adding in export PATH=/usr/local/Cellar/python/3.6.5_1/bin:$PATH
But it's still finding the wrong python. Any ideas where I'm going wrong?
EDIT:
When I run python3 -m ensurepip --upgrade I see this:
Requirement already up-to-date: setuptools in ./Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
Requirement already up-to-date: pip in ./Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
When I run python3 -m ensurepip -vvv -U I get this:
Ignoring indexes: https://pypi.python.org/simple
0 location(s) to search for versions of setuptools:
Skipping link /var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmpk6_9t6c2 (from -f); not a file
Skipping link file:///private/var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmpk6_9t6c2/pip-9.0.3-py2.py3-none-any.whl; wrong project name (not setuptools)
Found link file:///private/var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmpk6_9t6c2/setuptools-39.0.1-py2.py3-none-any.whl, version: 39.0.1
Local files found: /private/var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmpk6_9t6c2/setuptools-39.0.1-py2.py3-none-any.whl
Installed version (39.2.0) is most up-to-date (past versions: 39.0.1)
Requirement already up-to-date: setuptools in ./Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
0 location(s) to search for versions of pip:
Found link file:///private/var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmpk6_9t6c2/pip-9.0.3-py2.py3-none-any.whl, version: 9.0.3
Skipping link file:///private/var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmpk6_9t6c2/setuptools-39.0.1-py2.py3-none-any.whl; wrong project name (not pip)
Local files found: /private/var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmpk6_9t6c2/pip-9.0.3-py2.py3-none-any.whl
Installed version (10.0.1) is most up-to-date (past versions: 9.0.3)
Requirement already up-to-date: pip in ./Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
Cleaning up...
When I look in /usr/local/Cellar/python/3.6.5_1/bin/ with finder I don't see a pip/pip3 file.
Did you try to invoke /usr/local/Cellar/python3/3.6.5_1/bin/pip3 ? If it works, it means pip installation has been successfuly completed and your bashfile will be wrong. However, the bashfile looks normal for me.
Did you confirm that there is pip3 in /usr/local/Cellar/python3/3.6.5_1/bin/?
If it does not exist, pip is not installed in the first place.
It seems to have the same problem with this page ("pip3 not installed with python 3.4.2 #33897").
The questioner of "pip3 not installed with python 3.4.2 #33897" have finaly solved it by removing /private/var/folders/hy/l_6wd1ps0nz835v4g41zhhtr0000gn/T/pip_build.
It may be because of Brew had failed to complete pip installation.
First, to bootstrap the pip installer, hit python3 -m ensurepip --upgrade and python -m ensurepip.
If it won't work, try to hit python3 -m ensurepip -vvv -U and tell what do it say.
I'm not really sure why it worked this time but just for kicks I decided to uninstall and reinstall python from homebrew again but this time it worked and pip3 installed correctly and works.
brew uninstall python3
brew install python3
now I can run pip3 install numpy --user
I'n using pip 1.5.1 which worked fine up until today.
Now, I'm trying to install a requirements.txt in a fresh virtualenv, and for many packages it can no longer find specific old version for most packages.
$ pip install django-endless-pagination==1.1
Downloading/unpacking django-endless-pagination==1.1
Could not find a version that satisfies the requirement django-endless-pagination==1.1 (from versions: 2.0)
Some externally hosted files were ignored (use --allow-external to allow).
Cleaning up...
No distributions matching the version for django-endless-pagination==1.1
What do I need to do to get this to work again? Upgrading my app to use all the latest versions of all its packages is out of the question.
Update:
This works fine in pip 1.4.1. It's the newer version of pip that's causing it to fail.
From PIP 1.5 changelog:
BACKWARD INCOMPATIBLE
pip no longer will scrape insecure external urls by default nor will it install externally hosted files by
default. Users may opt into installing externally hosted or insecure
files or urls using --allow-external PROJECT and --allow-unverified
PROJECT
So in this case following ought to work the same way as old PIP:
pip install django-endless-pagination==1.1 \
--allow-all-external --allow-unverified django-endless-pagination
(There is no --allow-all-unverified, each unverified project name must be specified)
In case of using requirements.txt, it should be specified like this:
--allow-external django-endless-pagination
--allow-unverified django-endless-pagination
django-endless-pagination==1.1
In this case, you can use the URL of the appropriate zip file as input to pip install::
pip install https://github.com/frankban/django-endless-pagination/archive/v1.1.zip
Of course, not every package will have such a URL available, but most do.
I've occasionally used this to install the latest-greatest master, since in some cases the cheeseshop didn't have Python 3 ready packages yet.
Because the version on PyPI is 2.0 and pip now tries to honor the fact that maintainer wants you to use given version.
I am trying to install version 1.2.2 of MySQL_python, using a fresh virtualenv created with the --no-site-packages option. The current version shown in PyPi is 1.2.3. Is there a way to install the older version? I have tried:
pip install MySQL_python==1.2.2
However, when installed, it still shows MySQL_python-1.2.3-py2.6.egg-info in the site packages. Is this a problem specific to this package, or am I doing something wrong?
TL;DR:
Update as of 2022-12-28:
pip install --force-reinstall -v
For example: pip install --force-reinstall -v "MySQL_python==1.2.2"
What these options mean:
--force-reinstall is an option to reinstall all packages even if they are already up-to-date.
-v is for verbose. You can combine for even more verbosity (i.e. -vv) up to 3 times (e.g. --force-reinstall -vvv).
Thanks to #Peter for highlighting this (and it seems that the context of the question has broadened given the time when the question was first asked!), the documentation for Python discusses a caveat with using -I, in that it can break your installation if it was installed with a different package manager or if if your package is/was a different version.
Original answer:
pip install -Iv (i.e. pip install -Iv MySQL_python==1.2.2)
What these options mean:
-I stands for --ignore-installed which will ignore the installed packages, overwriting them.
-v is for verbose. You can combine for even more verbosity (i.e. -vv) up to 3 times (e.g. -Ivvv).
For more information, see pip install --help
First, I see two issues with what you're trying to do. Since you already have an installed version, you should either uninstall the current existing driver or use pip install -I MySQL_python==1.2.2
However, you'll soon find out that this doesn't work. If you look at pip's installation log, or if you do a pip install -Iv MySQL_python==1.2.2 you'll find that the PyPI URL link does not work for MySQL_python v1.2.2. You can verify this here: http://pypi.python.org/pypi/MySQL-python/1.2.2
The download link 404s and the fallback URL links are re-directing infinitely due to sourceforge.net's recent upgrade and PyPI's stale URL.
So to properly install the driver, you can follow these steps:
pip uninstall MySQL_python
pip install -Iv http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.2/MySQL-python-1.2.2.tar.gz/download
You can even use a version range with pip install command. Something like this:
pip install 'stevedore>=1.3.0,<1.4.0'
And if the package is already installed and you want to downgrade it add --force-reinstall like this:
pip install 'stevedore>=1.3.0,<1.4.0' --force-reinstall
One way, as suggested in this post, is to mention version in pip as:
pip install -Iv MySQL_python==1.2.2
i.e. Use == and mention the version number to install only that version. -I, --ignore-installed ignores already installed packages.
To install a specific python package version whether it is the first time, an upgrade or a downgrade use:
pip install --force-reinstall MySQL_python==1.2.4
MySQL_python version 1.2.2 is not available so I used a different version. To view all available package versions from an index exclude the version:
pip install MySQL_python==
I believe that if you already have a package it installed, pip will not overwrite it with another version. Use -I to ignore previous versions.
Sometimes, the previously installed version is cached.
~$ pip install pillow==5.2.0
It returns the followings:
Requirement already satisfied: pillow==5.2.0 in /home/ubuntu/anaconda3/lib/python3.6/site-packages (5.2.0)
We can use --no-cache-dir together with -I to overwrite this
~$ pip install --no-cache-dir -I pillow==5.2.0
Since this appeared to be a breaking change introduced in version 10 of pip, I downgraded to a compatible version:
pip install 'pip<10'
This command tells pip to install a version of the module lower than version 10. Do this in a virutalenv so you don't screw up your site installation of Python.
This below command worked for me
Python version - 2.7
package - python-jenkins
command - $ pip install 'python-jenkins>=1.1.1'
I recently ran into an issue when using pip's -I flag that I wanted to document somewhere:
-I will not uninstall the existing package before proceeding; it will just install it on top of the old one. This means that any files that should be deleted between versions will instead be left in place. This can cause weird behavior if those files share names with other installed modules.
For example, let's say there's a package named package. In one of packages files, they use import datetime. Now, in package#2.0.0, this points to the standard library datetime module, but in package#3.0.0, they added a local datetime.py as a replacement for the standard library version (for whatever reason).
Now lets say I run pip install package==3.0.0, but then later realize that I actually wanted version 2.0.0. If I now run pip install -I package==2.0.0, the old datetime.py file will not be removed, so any calls to import datetime will import the wrong module.
In my case, this manifested with strange syntax errors because the newer version of the package added a file that was only compatible with Python 3, and when I downgraded package versions to support Python 2, I continued importing the Python-3-only module.
Based on this, I would argue that uninstalling the old package is always preferable to using -I when updating installed package versions.
There are 2 ways you may install any package with version:-
A). pip install -Iv package-name == version
B). pip install -v package-name == version
For A
Here, if you're using -I option while installing(when you don't know if the package is already installed) (like 'pip install -Iv pyreadline == 2.* 'or something), you would be installing a new separate package with the same existing package having some different version.
For B
At first, you may want to check for no broken requirements.
pip check
2.and then see what's already installed by
pip list
3.if the list of the packages contain any package that you wish to install with specific version then the better option is to uninstall the package of this version first, by
pip uninstall package-name
4.And now you can go ahead to reinstall the same package with a specific version, by
pip install -v package-name==version
e.g. pip install -v pyreadline == 2.*
If you want to update to latest version and you don't know what is the latest version you can type.
pip install MySQL_python --upgrade
This will update the MySQL_python for latest version available, you can use for any other package version.
dependency packaging has had a new release, wherein it has dropped LegacyVersion from its codebase
The quick solution might be pin packaging==21.3