I have python 2.7 & 3.5 on my system. When I use sudo, easy_install, or pip to install a package it installs to 2.7.
How do I tell pip, sudo, easy_install to install the package to 3.5?
Example:
This installs pytest to 2.5
pip install -U pytest
What would be the equivalent to install to 3.5?
The simplest way to install any pip package with specifying version is:
For Python 2.7:
pip install <package_name>
For Python 3.x
pip3 install <package_name>
This works on all the platforms, be it Linux, Windows or Mac if you have pip package manager installed.
It seems you're trying to install packages using pip on mac. Since the default python version is 2.7 for mac therefore the default pip also installs to python 2.7. In order to install to a custom version you can specify it like this:
python3 -m pip install package
#or
python3.5 -m pip install package
#ie
python3.5 -m pip install -U pytest
On Windows, use the py Python launcher in combination with the -m switch:
es:
py -2 -m pip install SomePackage # default Python 2
py -2.7 -m pip install SomePackage # specifically Python 2.7
py -3 -m pip install SomePackage # default Python 3
py -3.4 -m pip install SomePackage # specifically Python 3.4
On Linux, Mac OS X, and other POSIX systems, use:
python2 -m pip install SomePackage # default Python 2
python2.7 -m pip install SomePackage # specifically Python 2.7
python3 -m pip install SomePackage # default Python 3
python3.4 -m pip install SomePackage # specifically Python 3.4
Related
mistakenly first i installed python 3.6 then install pip,then i install python 3.8 after that i checked the pip version its shows me.
pip 20.1.1 from /usr/local/lib/python3.6/dist-packages/pip (python 3.6)
Can i change to
pip 20.1.1 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)
If you want to ensure pip is using the python version you desire, you can use:
python3.8 -m pip ...
instead of the bare:
pip ...
The following should work:
$ python3.8 -m pip install pip
$ python3.6 -m pip uninstall pip
I'm setting up virtual env. I was getting warnings about an outdated pip (19.2) so I updated pip on my (macos) system globally, sudo -H python3 -m pip install --upgrade pip. It seems to have worked, but when I make a new venv, I'm still getting the old pip version.
% pip --version
pip 20.1 from /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip (python 3.8)
% python3 -m pip --version
pip 20.1 from /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip (python 3.8)
% rm -rf .venv # make sure
% python3 -m venv .venv
% . .venv/bin/activate
(.venv) % python3 -m pip --version
pip 19.2.3 from /Users/marvin/.venv/lib/python3.8/site-packages/pip (python 3.8)
(.venv) % pip --version
pip 19.2.3 from /Users/marvin/.venv/lib/python3.8/site-packages/pip (python 3.8)
Where is the older version coming from?
Pip is installed anew in any freshly created venv. The venv's default pip version is associated with the Python version, and is completely independent from whatever pip version you may have installed on the system. The older version comes from a wheel file bundled with the stdlib ensurepip module. This allows users to create a venv even with no internet connection available, as the venv docs mention:
Unless the --without-pip option is given, ensurepip will be invoked to bootstrap pip into the virtual environment
You can check the bundled pip version with ensurepip.version:
>>> import ensurepip
>>> ensurepip.version()
'19.2.3'
Python 3.8.2 is vendoring pip 19.2.3 and setuptools 41.2.0, matching what you've seen.
To create venvs directly with the latest pip version, rather than creating them with an older pip and then upgrading the pip version, refer to this answer:
How to get “python -m venv” to directly install latest pip version
I am seeing some weird stuff on my system:
$ pip install python-binance-api
...Library/Python/2.7/lib/python/site-packages (from python-binance-api) (3.13.2)
...
python versions:
$ python --version
Python 2.7.14
10:05 PM ~/kittycapital add_more_curr
$ python3 --version
Python 3.6.4
My pip is still installing to python 2.7 when I want it to install on python3. How do I get it to do this?
If I want the commands pip and python to point to python 3.7, what can I do?
Solution 1
python3 -m pip install xxx
# for example: python3.7 -m pip install requests
Solution 2
virtualenv --python=python3.7 venv
source venv/bin/activate
pip install requests
Solution 3
pipenv --python 3.7 # python3 -m pip install pipenv --user
pipenv shell
pipenv install requests
I have missing module and I don't know how do I install this. Is there a newer version? I want to do something like: python3.6 -m smtpd -n -c DebuggingServer localhost:1025
Try This.. For Python: 3.6
From pip install Smtpd
pip install smtpd-tls
install the latest version of a module and its dependencies from the
Python Packaging
python -m pip install SomePackage
For Specific Version and Minimum Version Install
python -m pip install SomePackage==3.6.1 # specific version
python -m pip install "SomePackage>=1.0.4" # minimum version
For More Read This : https://docs.python.org/3/installing/index.html
For Smtpd Read This : https://pypi.python.org/pypi/smtpd-tls/0.1
This question already has answers here:
How to install pip for python 2.6?
(4 answers)
Closed 6 years ago.
I just installed Ubuntu 16.04 which includes Python 2.7.11 and 3.5.1.
I also installed Python 3.4.4 successfully. But when I try to install numpy with:
sudo apt-get install python-numpy
sudo apt-get install python3-numpy
it installs for Python 2.7.11 and 3.5.1 but I need it for Python 3.4.4. How do I install it?
From python docs: when working with multiple versions of Python installed in parallel, below commands can be used along with pip to install a Python Package for a particular version of Python:
python2 -m pip install SomePackage # default Python 2
python2.7 -m pip install SomePackage # specifically Python 2.7
python3 -m pip install SomePackage # default Python 3
python3.4 -m pip install SomePackage # specifically Python 3.4
python3.5 -m pip install SomePackage # specifically Python 3.5
Hence, to install numpy package for Python3.4, you can use this command:
~/$ python3.4 -m pip install numpy