Leustad
Leustad

Reputation: 143

How to pip install packages into different versions of Python

I have 2 Python versions

Env variable works with Python 3.4(in my system), so when I pip install*package_name it will only install the package into Python 3.4

I have a system variable for Python 2.7 -- %python27% -- also.

My question is; how can I pip install a package/module into Python 2.7 without changing the Env. Variable.

Note: %python27% pip install *package_name doesn't work.

Thank you.

Upvotes: 1

Views: 2621

Answers (3)

JML35
JML35

Reputation: 1

I had the same problem, but it was installing to Python 2.7 rather than Python 3.4. Using $ pip3 install *package_name solved the issue.

Upvotes: 0

Grzegorz Wójcicki
Grzegorz Wójcicki

Reputation: 124

You should have multiple executables of pip.

Use pip2 and pip3 interchangeably.

Anyway, you should consider using virtualenv package, initialize it like virtualenv -p /usr/bin/python2.7 env_name or virtualenv-3.4 -p /usr/bin/python3.4 env_name then each time you use your code, type source env_name/bin/activate and "python" should be aliased to virtualised version.

Upvotes: 2

Morishiri
Morishiri

Reputation: 884

You can use pip for python2 and pip3 for python3. Also you can try using virtualenv or pyenv

Upvotes: 0

Related Questions