Reputation: 11
I have on my machine (windows 10) two versions of python: 3.5 2.7
I need to install a package using pip but I want the package on both.
My default version is 3.5.
I try to do this: pip2 install scikit-learn
to install it on python 2.7 and I get this error:
Traceback (most recent call last):
File "c:\python27\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "c:\python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\Scripts\pip2.exe\__main__.py", line 5, in <module>
File "c:\python27\lib\site-packages\pip\__init__.py", line 13, in <module>
from pip.commands import commands, get_similar_commands, get_summaries
File "c:\python27\lib\site-packages\pip\commands\__init__.py", line 6, in <module>
from pip.commands.bundle import BundleCommand
File "c:\python27\lib\site-packages\pip\commands\bundle.py", line 5, in <module>
from pip.commands.install import InstallCommand
File "c:\python27\lib\site-packages\pip\commands\install.py", line 5, in <module>
from pip.req import InstallRequirement, RequirementSet, parse_requirements
File "c:\python27\lib\site-packages\pip\req\__init__.py", line 3, in <module>
from .req_install import InstallRequirement
File "c:\python27\lib\site-packages\pip\req\req_install.py", line 20, in <module>
import pip.wheel
File "c:\python27\lib\site-packages\pip\wheel.py", line 27, in <module>
from pip.download import path_to_url, unpack_url
ImportError: cannot import name unpack_url
I also try this: python2.7 -m pip install scikit-learn
or python27 -m pip install scikit-learn
and I get this error:
python2.7 : The term 'python2.7' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try agai
At line:1 char:1
+ python2.7 -m pip install scikit-learn
+ ~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (python2.7:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I do have python 2.7 on C:\Python27
.
What to do?
Upvotes: 0
Views: 1024
Reputation: 11
Thanks allot for the answers,
after some try&fail I find 2 different ways to figure it.
1. <PATH-FOR-PYTHON>\scripts\pip.exe install <package name>
2.
py -2 -E-m pip install scikit-learn for v3.5
py -3 -E -m pip install scikit-learn for v2.7
Upvotes: 0
Reputation: 2656
On Windows you can use
for python2.x py -2
for python3.x py -3
so it would be
py -2 -m pip install scikit-learn
py -3 -m pip install scikit-learn
just try py --help
for more info
Upvotes: 1
Reputation: 183
The safest and least frustrating way to go about this is to load independent copies of scikit learn into two virtual environments.
Install by:
$ pip install virtualenv
$ pip install virtualenvwrapper
Then
$ mkvirtualenv --python=<path to python> <name virtualenv>
To run it...
workon <name virtualenv>
Upvotes: 1