This question already has an answer here:
pip version mismatch in venv
(1 answer)
Closed 4 years ago.
I have a virtual environment SystemModeling. I expect behavior like this:
(SystemModeling) Name-MacBook-Pro:thermofluids name$ pip --version
pip 9.0.3 from /Users/name/.virtualenvs/SystemModeling/lib/python3.6/site-packages (python 3.6)
But instead, it appears to be using pip from a the python 2.7 in my system library:
(SystemModeling) Name-MacBook-Pro:thermofluids name$ pip --version
pip 9.0.1 from /Library/Python/2.7/site-packages (python 2.7)
This is causing all kinds of issues when I try to use pip to do anything.
One possibility is shell command cache; you can clear the command cache using (bash, zsh)
hash -r
If that does not work, instead of using pip, try python -m pip to force using pip installed for current environment's python executable.
Related
I may be leaving out many details, but I'll attempt to construct the best picture of what is happening here.
My Mac is running OS Catalina 10.15.6, I got it back in April, and it has Python 2.7 in
I'm learning to use pip install and PyPI from terminal, and the first oddity I noticed was that I had to install pip. I shouldn't have, because it comes with Anaconda Navigator. So I did sudo easy-install pip and it installed. Then I did pip install requests which worked fine, then pip install colorama and then it threw this error message:
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: colorama in ./Library/Python/2.7/lib/python/site-packages (0.4.3)
My desire is to be able to use the Anaconda Python from terminal, since this 2.7 Python is dying and I need to be able to do so for my upcoming bootcamp and current Python course. I tried many conda commands to create an environment, see my current environment, etc, and they all failed because my terminal doesn't recognize conda as a command. I see this:
ryanlindsey#Ryans-MacBook-Pro ~ % conda info --envs
zsh: command not found: conda
ryanlindsey#Ryans-MacBook-Pro ~ % conda create -n myenv python=3.6
zsh: command not found: conda
ryanlindsey#Ryans-MacBook-Pro ~ % conda
zsh: command not found: conda
I've read stack overflow suggestions to add it to my path, but even when I use the code it seems to do nothing.
If this is useful, here is my PATH when I do echo $PATH
/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
My shell I am using is zsh.
Anyone experienced in solving problems like this?
MacOS comes with python 2.7 installed by default. You can't move or remove it. Catalina also comes with python 3.7 (though it requires the download of Xcode command line tools when first run to complete it.)
Usually, python 3 versions are instigated with the command python3. Similarly, pip3 manages libraries for python 3, while pip manages libraries for python 2.
It doesn't look like you've actually installed Anaconda. Anaconda is a third-party product, which does not come bundled with the OS. You'll need to install that and follow the instructions on their website.
https://docs.anaconda.com/anaconda/install/
I am confused about different python versions on my Computer and in Anaconda.
First: I use an iMac (OSX Catalina).I sometimes use the command line (Terminal on my iMac) directly and sometimes I use Anaconda Navigator (for example when I want to work with Jupyter Notebooks).
When I type python3 --version, I get the answer that I have python 3.8.0 installed. But recently, I installed the latest pip version with pip3 --user --upgrade pip. The answer I got was:
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
pip 20.0.2 from /Users/Andrea_5K/Library/Python/3.7/lib/python/site-packages/pip (python 3.7)
I wondered why in this message python 3.7 is referenced.
When I check my Library/Python folder in my user folder I see that I have a 3.7 folder and a 3.8 folder as well. Is there something wrong? Is pip 20.0.2 now installed on python 3.7 although I use python 3.8? And what does the WARNING message mean?
I made a pip package and uploaded it here:
https://pypi.org/project/audacityDiscogsExporter/0.1.0/
If i run pip install audacityDiscogsExporter==0.1.0 or pip install audacityDiscogsExporter I get an error saying :
martin#MSI:/mnt/c/Users/marti/Documents/projects/package$ pip install audacityDiscogsExporter
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement audacityDiscogsExporter (from versions: none)
ERROR: No matching distribution found for audacityDiscogsExporter
Why can't I install this package?
It looks like you are trying to use a Python 2 interpreter to install a Python-3-only project.
When using pip (or actually any other Python script directly), it is important to make sure which Python interpreter is used. Usually it is obvious which Python interpreter is used when calling pip, but it also often happens that it is not clear. It is better to call the exact Python interpreter explicitly always. Typically:
$ python -m pip install Something
$ # instead of 'pip install Something'
$ python3 -m pip install Something
$ # instead of 'pip3 install Something'
If there is still doubt, one could even go one step further and use the full path to the Python interpreter explicitly:
$ /usr/bin/python3.8 -m pip install Something
$ /path/to/myvenv/bin/python3 -m pip install Something
An interesting read on the topic: Brett Cannon's article "Why you should use python -m pip"
This question already has answers here:
How do I install pip on Windows?
(40 answers)
Closed 4 years ago.
On my computer (windows 8.1) there is python 3.4.
When I try to install module with pip install the code that I use is:
py -m pip install ...
But the command line returns the following error:
C:\Python34\python.exe: No module named pip.__main__; 'pip' is a package and cannot be directly exec
uted
Pip is just not a standalone executable. It is a python module.
So as a matter of fact you can do this (Tested with numpy, worked correctly as wanted):
python -m pip install numpy
Well, you should see the documentation on Python.
I did mention that Pip is a standalone executable. If it is in you path then you can also do this:
pip install numpy
Make sure python is in your path.
I have two versions of Python in my laptop. Python 2.7 and Python 3.6. If install a module this is installed only in Python 3.6.
I would like to install modules in Python 2.7 through pip but I don't know how to do it.
I want to install right now GDAL and Fiona for Python 2.7 in Ubuntu 17.04.
If Python 2.7 is well installed on your system, you should have python2 and/or python2.7 commands and you could run the following:
python2.7 -m pip install <your-packages>
To make sure you are running the correct python version, you can use python2.7 --version
Better use virtual environment for this.
Follow this link https://realpython.com/blog/python/python-virtual-environments-a-primer/
You can set python version to use in virtual env using
virtualenv -p path/to/python2.7 env_name
Activate this env using . env_name/bin/activate then,
Use pip install package_name to install libraries inside virtual environment