I'm using Kali dist so I have already installed Python 2.7, 3.5 and 3.6. Commands 'python' and 'pip' are associated with Python 2.7. But the 'python3' uses Python 3.6 while pip3 is installing packages for Python 3.5.
When I tried to create an venv:
pip3 -p python3.6 virtualenv myenv
I've got an error:
no such option: -p
How can I associate pip3 with Python 3.6 instead of Python 3.5?
When you install Python3, see if there's a comment such as this:
Ignoring ensurepip failure: pip 9.0.1 requires SSL/TLS
You might see entries like this in the log:
This answer describes using ensurepip https://stackoverflow.com/a/38250442/1607937
Also see this regarding openssl "SSL module in Python is not available" when installing package with pip3
First find the right version of python you want to use:
then invoke that instance of python directly, e.g.
Next,
pip
does not create virtual environments. The modulevenv
does. Read thevenv
documentation for recommended usage. In your case, you might want:Your version of pip is inextricably linked to your version of Python, you cannot tell pip "use this Python" or "use that Python." If you have a version mismatch between pip3 (using Python 3.X) and python3 (being Python 3.Y), it means your problem is with multiple overlapping distributions of Python and a weirdly configured
$PATH
.If you run
pip3 --version
it will tell you the site-packages directory and Python version number that pip3 is associated with.If you run
python3
and then execute>>> import site; site.getsitepackages()
, it should print the site-packages directory yourpython3
is using.If these do not match, you've got path problems and you'll need to post more information about what operating system you're on, what Python distributions you're using, and how you installed them.
Update/Summary of Comment Thread: Original poster had a distribution-bundled Python 3.6 installed alongside a self-installed Python 3.5. The pip3 on their path was associated with Python 3.6 (system Python), while the command python3 was associated with Python 3.5 (their self-installed Python). Resolution:
Run
which -a python3
to find Python 3.5. Add the location of Python 3.5 to your$PATH
. (Do it in.profile
or.bash_profile
to make it permanent.)You can explicitly run the
pip3
script with a particular Python version, by prefixing it with the appropriatepython3.
x command: