Install module in Python 2.7 and not in Python 3.3 - python

I'm working on mac OS X and I have both Python 2.7 and 3.3 on it. I want to install pykml module and i successfully installed it on python 3.3, but how do I do the same for Python 2.7?

You can do this if pip version >=1.5
$ pip2.6 install package
$ pip3.3 install package
if pip version is between 0.8 and 1.5 this will work
$ pip-2.7 install package
$ pip-3.3 install package

Related

Install pip for specific python version

We have installed python 3.9 from external Link, my OS has in built python 3.6 and python3-pip for 3.6 version. If I install pip packages it will install for python 3.6 and it is not compatible for python 3.9. How to install pip3.9 ? so that i will install packages from pip3.9 command.
OS: Cent OS
I tried like this
python3.9 -m pip
python3.9: No module named pip
Some Python distributions may not come with pip installed. Try
python3.9 -m ensurepip
to install pip for your interpreter first.
Adding on #Selcuk 's answer, you can define which python version runs pip:
For example:
/path/to/python3.9/python -m pip install mypackage
This would install mypackage for the python version you referenced to.
Another suggestion is to use Conda, which handles different python versions pretty effectively.

How can the libraries installed in python 3.6 be used in python3.7

I installed the following library in python 3.6 using the following command
pip3 install CANard
How can I install the same library in python 3.7 if I give
pip3.7 install CANard
it says command not found

Python pip packages installation

I have both python 2.7 and python 3.5.2 installed, both open IDLE just fine, my question is, if I go into the Cmd on Windows and type python it goes for the 2.7 version, how do I set it up so I have something like python2 and python3?
And finnally if i run python pip install package how do I know if it's installing for python 2.7 or 3.5.2.
You can use Python Launcher in Windows CMD.
Execute script:
py -2.7 path_to_my_script.py
or:
py -3.5 path_to_my_script.py
You can use pip the same way:
py -2.7 -m pip install numpy
for install NumPy in Python 2.7 or:
py -3.5 -m pip install numpy
for install NumPy in Python 3.5
Rather than using pip, use pip2 when targeting Python 2, and pip3 for Python 3.
Windows does have these pip2 and pip3 version-specialized commands.
If you already installed a package and want to know what Python version of the package you installed, run an interpreter and import it.
python2
>>> import package
ImportError: No module named 'package'
python3
>>> import package
>>>

Install Python 3.5.2, but pip for Python 2.6

VPS-server was a version Python 2.6, I installed version Python 3.5.2.
When I try to install some packages with help pip, I got errors.
During installation packages:
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
Versions:
# Python -V
# Python 3.5.2
# pip -V
# pip 8.1.2 from /usr/lib/python2.6/site-packages/pip-8.1.2-py2.6.egg (python 2.6)
# cat /etc/*-release
# CentOS release 6.8 (Final)
How to change path to pip from python 3.5 ?
if you haven't pip in server you can use get-pip file:
after install python usually installed pip and you can run by pip3 command
for example you can use:
pip3 install netaddr
Upgrading pip manually solved this issue for me once. Update pip Documentation
pip is already installed if you're using Python 2 >=2.7.9 or Python 3 >=3.4 downloaded from python.org, but you'll need to upgrade pip.
On Linux or OS X:
pip install -U pip
On Windows [5]:
python -m pip install -U pip

How do you install PyDDE to Python 3.4 and not Python 2.4

I am currently trying to install the PyDDE package.
Going to the command line and running pip install PyDDE initially didn't work, so I downloaded the zip package from https://github.com/hensing/PyDDE
and then I navigated to the unzipped folder and used the python setup.py command as specified in the installation instruction.
This installed the PyDDE module in python 2.7, and typing import PyDDE yields the module in 2.7. However, it does not install in 3.4.
I found this similar problem on stackoverflow (
Python 3.4 and 2.7: Cannot install numpy package for python 3.4
Installing numpy for Python 2.7 while also having Python 3.4 installed?
which provided solutions like using sudo pip and going to the python 3.4 folder and using easy_install PyDDE
Since it is already installed for python 2.7 when I use:
easy_install PyDDE or
pip install PyDDE
it happily tells me that pydde 0.2.2 is already installed/the active version, however, loading up Python 3.4 and importing PyDDE still doesn't work.
I have also tried python34 install PyDDE but python34 isn't a recognised command.
Any help would be appreciated.
You need to use pip3:
pip3 install PyDDE
pip installs python2 packages and pip3 does your python3 packages.
You need python3 in your pythonpath go to:
My Computer/Properties/Advanced System Settings/Environment Variables
And add C:\Python34\;C:\Python34\Scripts\ to your pythonpath.
Then download get-pip.py and run python34 get-pip.py

Categories