3

When I try to install packages (any package) using pip3.6 installations do not go into the correct python version. instead they go into 2.7

$ pip3.6 install sklearn
Collecting sklearn
  Downloading sklearn-0.0.tar.gz
Collecting scikit-learn (from sklearn)
  Downloading scikit_learn-0.19.1-cp36-cp36m-manylinux1_x86_64.whl (12.4MB)
    100% |████████████████████████████████| 12.4MB 138kB/s 
Installing collected packages: scikit-learn, sklearn
  Running setup.py install for sklearn ... done
Successfully installed scikit-learn-0.19.1 sklearn-0.0
Target directory /usr/lib/python2.7/dist-packages/scikit_learn-0.19.1.dist-info already exists. Specify --upgrade to force replacement.
Target directory /usr/lib/python2.7/dist-packages/sklearn-0.0-py3.6.egg-info already exists. Specify --upgrade to force replacement.
Target directory /usr/lib/python2.7/dist-packages/sklearn already exists. Specify --upgrade to force replacement.

Note the python2.7 in Target directory /usr/lib/python2.7/dist-packages/scikit even though i am using pip3.6

When I try to import in python3.6, the package is not found

$ python3.6
Python 3.6.1 (default, Feb  7 2018, 17:00:49) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sklearn
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'sklearn'

The correct python version is mentioned in the pip3.6 file

$ cat /usr/local/bin/pip3.6
#!/usr/local/bin/python3.6

# -*- coding: utf-8 -*-
import re
import sys

from pip import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

And pip3.6 appears to be pointing to the correct python version

$ pip3.6 -V
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

Any thoughts on how to get pip3.6 to install packages in the correct python folders?

Ricky Sahu
  • 23,455
  • 4
  • 42
  • 32
  • Possible duplicate of [Pip Install not installing into correct directory?](https://stackoverflow.com/questions/25607837/pip-install-not-installing-into-correct-directory) – Xantium Feb 07 '18 at 22:57
  • 1
    Your pip installation is screwed up (probably from using sudo incorrectly). I would uninstall them all and reinstall. – wim Feb 07 '18 at 22:59

1 Answers1

1

the -t parameter allows specification of the target path to install packages where they need to go. this ended up working but doesn't solve the root problem

python3.5 -m pip install scikit-learn -t /usr/lib/python3.5/
Ricky Sahu
  • 23,455
  • 4
  • 42
  • 32
  • In case this helps someone: I had a similar problem where I installed packages using `pip3.6`, but the packages ended up in the 3.5 folder. My mistake was using the `--user` flag. Removing that flag and instead adding `-t /home/myuser/.local/lib/python3.6/site-packages` solved it. – L42 Feb 19 '18 at 12:41