15

SOLUTION My user did not own permissions to the pip directory, I reinstalled Python 3.5 using the sudo -H flag

I'm trying to install Tensorflow for python 3.5 using pip3 -- for reasons described in this github issue -- but when I install using sudo pip3 install *.whl it installs to python 3.4.

How can I redirect pip3 to install into my python 3.5 directory?

I'm running on Ubuntu 14.04

kendall@kendall-Macmini:~/Downloads$ python3.4 -m pip --version
pip 8.1.2 from /usr/local/lib/python3.4/dist-packages/pip-8.1.2-py3.4.egg (python 3.4)
kendall@kendall-Macmini:~/Downloads$ python3.5 -m pip --version
/usr/local/bin/python3.5: No module named pip

It looks like I don't even have pip installed for python 3.5. How can I do this?

I've tried

kendall@kendall-Macmini:~/Downloads$ pip install -U pip
Requirement already up-to-date: pip in /usr/local/lib/python3.4/dist-packages/pip-8.1.2-py3.4.egg

Also,

kendall@kendall-Macmini:~/Downloads$ whereis pip
pip: /usr/bin/pip /usr/bin/X11/pip /usr/local/bin/pip3.4 /usr/local/bin/pip /usr/local/bin/pip2.7 /usr/share/man/man1/pip.1.gz

I can't find any support for upgrading to pip3.5

UPDATE

kendall@kendall-Macmini:~/Downloads$ sudo apt-get install python3-setuptools
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-setuptools is already the newest version.
The following packages were automatically installed and are no longer required:
  libntdb1 linux-headers-4.2.0-27 linux-headers-4.2.0-27-generic
  linux-image-4.2.0-27-generic linux-image-extra-4.2.0-27-generic
  linux-signed-image-4.2.0-27-generic python-ntdb
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
kendall@kendall-Macmini:~/Downloads$ sudo python3.5 easy_install.py pip
python3.5: can't open file 'easy_install.py': [Errno 2] No such file or directory
kendall@kendall-Macmini:~/Downloads$ python3.5 -m ensurepip
Ignoring ensurepip failure: pip 8.1.1 requires SSL/TLS
kendall@kendall-Macmini:~/Downloads$ sudo apt-get install pip3
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package pip3


kendall@kendall-Macmini:~/Downloads$ sudo apt-get install libssl-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libssl-dev is already the newest version.
The following packages were automatically installed and are no longer required:
  libntdb1 linux-headers-4.2.0-27 linux-headers-4.2.0-27-generic
  linux-image-4.2.0-27-generic linux-image-extra-4.2.0-27-generic
  linux-signed-image-4.2.0-27-generic python-ntdb
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
kendall@kendall-Macmini:~/Downloads$ python3.5 -m ensurepip
Ignoring ensurepip failure: pip 8.1.1 requires SSL/TLS

As recommended by @fwalsh

kendall@kendall-Macmini:~/Downloads$ python3.5 get-pip.py 
Traceback (most recent call last):
  File "get-pip.py", line 19177, in <module>
    main()
  File "get-pip.py", line 194, in main
    bootstrap(tmpdir=tmpdir)
  File "get-pip.py", line 82, in bootstrap
    import pip
zipimport.ZipImportError: can't decompress data; zlib not available

It seems like I'm missing all sorts of dependencies -- I'm going to try reinstalling

Kendall Weihe
  • 2,021
  • 4
  • 27
  • 53

3 Answers3

17

Check: /usr/local/lib/python3.5/dist-packages

You'll either have Pip there or easy_install(part of Pythons setup tools), which can be used to install Pip:

sudo apt-get install python3-setuptools
sudo python3.5 easy_install.py pip

Or you can try:

python3.5 -m ensurepip

Another option is attempting to install from a repository, the package name depends on your distribution:

sudo apt-get install python3-pip pip3

Edit: Try this correction for easy install:

sudo apt-get install python3-setuptools
sudo python3.5 /usr/local/lib/python3.5/dist-packages/easy_install.py pip

I'm assuming that's the directory it's installed to.

Also, you're missing this library for the python3.5 -m ensurepip command:

sudo apt-get install libssl-dev
L Martin
  • 1,180
  • 8
  • 18
  • added update in the post. I'm beginning to think my python 3.5 install went wrong somewhere. Should I reinstall? – Kendall Weihe Jul 07 '16 at 16:14
  • updated again, and again, is something wrong with my python 3.5 install? lol – Kendall Weihe Jul 07 '16 at 16:17
  • Did you install it from a repository or did you compile it yourself? – L Martin Jul 07 '16 at 16:18
  • 1
    I installed from the source https://www.python.org/downloads/ although now that I think about it, I'm beginning to think I installed the wrong source (wrong OS?) I clicked on the large `Download Python 3.5.21 button at the top of the page -- I'm running linux **SCRATCH THIS IDEA** – Kendall Weihe Jul 07 '16 at 16:20
  • 17
    `easy_install.py` simply does not exist in my python 3.5 directory – Kendall Weihe Jul 07 '16 at 16:23
  • I've added a few extra commands to try and help. Looks like Python setuptools is missing if you don't have easy_install. And the Open SSL library is ensurepip is complaining about a lack of SSL – L Martin Jul 07 '16 at 16:24
  • adding the setuptools still doesn't add easy_install. same error message -- what's with the `3 not upgraded` ? – Kendall Weihe Jul 07 '16 at 16:27
  • Try installing the open ssl library and running ensurepip again. It's a surefire way for Python to retrieve a copy of Pip when you need it. – L Martin Jul 07 '16 at 16:29
  • it's as if it is only seeing python 3.4. trying to reinstall python 3.5 now. This could also be a problem with the latest 3.5 release, I'm also going to try reinstalling with older releases – Kendall Weihe Jul 07 '16 at 16:35
  • 2
    Ah I found the issue! My user did not own the pip directory, I had to use the -H flag – Kendall Weihe Jul 07 '16 at 16:44
  • weird my `/usr/local/lib/python3.5/dist-packages` is completely empty. Not even pip. But I `python3.5` command seems to work fine. – Charlie Parker Feb 08 '17 at 21:44
  • You can copy the pip package to it from another 3.x installation. Then do: python3.5 -m pip install --upgrade pip to make sure it's the most recent version. The -m makes it look in dist-packages for pip - unless you've installed a python3-pip deb package or created a bash alias you won't be able to just use 'pip3' – L Martin Feb 09 '17 at 11:57
  • The correct install is `apt-get install python3-pip` – CatCatMcMeows Mar 24 '18 at 23:11
  • What if I am not on Linux so I don't have `apt-get`? – Ky - Sep 01 '19 at 06:12
  • My `/usr/local/lib/python3.5/dist-packages` is completely empty... – Cerin Aug 30 '21 at 22:43
0

All the various Python 3.* versions seem to re-use the same pip location, which makes it difficult to call for a specific Python version.

However, you can call pip for a specific version by specifying it as a module. So instead of doing:

pip3.5 install <blah>

which doesn't exist on most distros, do:

python3.5 -m pip install <blah>
Cerin
  • 60,957
  • 96
  • 316
  • 522
-1

Try

sudo add-apt-repository ppa:deadsnakes/ppa

sudo apt update
sudo apt install python3.8 python3.8-dev python3.8-venv

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2

python3 -V
Andrew Nodermann
  • 610
  • 8
  • 13