how to run easy_install using a particular python version - python

I have 3 python versions, I want to easy_install Orange using the second version. How can I do this?
Unnecessary info:
2.1 in /usr/bin/python
2.6 in /Library/Frameworks/Python.framework/Versions/2.6/bin/python
3.1 in /Library/Frameworks/Python.framework/Versions/3.1/bin/python
Answer:
Ok found it here (http://peak.telecommunity.com/DevCenter/EasyInstall#multiple-python-versions),
"Also, if you're working with Python version 2.4 or higher, you can run Python with -m easy_install to run that particular Python version's easy_install command"

Just so the answer is easy to find:
Using "Python-version" with the m-parameter and easy_install afterwards does the trick.
Example:
python2.7 -m easy_install https://bitbucket.org/james_taylor/bx-python/get/tip.tar.bz2

easy_install is usually/always installed per Python version. So you run the related version of easy_install installed for your particular Python version/interpreter you want to use here.

Say your python version is 3.5. Then you can use the command easy_install-3.5 followed by the name of the module you are willing to download/install. See documentation here.

From the doc, besides the reported option
python2.7 -m easy_install
there is also:
if you install EasyInstall for both Python 2.3 and 2.4, you can use the easy_install-2.3 or easy_install-2.4 scripts to install packages for Python 2.3 or 2.4

Related

Package management for coexisting Python 2 and 3

I have been using Python 2.7 for a while now and installing packages using pip install without any issue. I just started using python 3 for a certain code and realized how confusing having different versions of Python can get.
I have Fedora 25, the default Python version is 2.7.13 and the default Python 3 version is Python 3.5.3,
I want to be able to use python 2.7 and python 3, my general question is:
What are the best practices when installing packages for both Python 2 and Python 3 on one machine?
As I mentioned using pip install in Python 2.7 works fine, but what about Python 3? I can:
use pip3 install
use python3 -m pip install
Which one should I use and how does it affect the python 2 version of the module? pip3 is not installed on Fedora 25, which raises a new question: how should I install it? as I understand I can:
use dnf install python3-pip (it is unclear if that actually works when pip for Python 2.7 is installed)
use python3 get-pip.py
Finally, would it be a good idea to create a Python 2 and a Python 3 virtual environment to address this issue?
From what I have read on the internet there does not seem to be a clear consensus on these questions, I hope this thread will clarify.
pip3 install and python3 -m pip install — both work perfectly and don't have any impact on Python 2. You can have as many Pythons in your system as you want; I for one have Python 2.7, 3.4, 3.5 and 3.6. To distinguish different versions of pip I use versioned names: pip3.4 install.
And of course I use virtual environments and virtualenvwrapper quite intensively.

Module working in Python 2.7 but getting ImportError in 3.4

I'm trying to run some modules in Python 3.4 that work fine for me in 2.7. tweepy and pexpect are two examples. Unfortunately, in 3.4 on the same Mac, I'm getting "ImportError: No module named 'pexpect'"
Looking at pypi.python.org, I see that tweepy lists Python 3 and Python 3.4 while pexpect lists only Python 3.
To rectify my problem, I've tried upgrading and sudo installing the modules through both pip and pip3.
I'm running Mac OSX El Capitan. I installed 3.4 via the download and instructions at python.org and not through homebrew, et al. pip --version returns: "pip 7.1.2 from /Library/Python/2.7/site-packages (python 2.7)"
I've seen similar questions on StackOverflow, but answers seem to be Linux specific (Importing modules that work in Python 2.7 but not Python 3.4 and How to use pip with Python 3.x alongside Python 2.x) or the answers are not working for me.
Can someone provide me with some insight into what I'm missing?
The Python 3 documentation on Installing Python Modules says that you must install pip for your version and call it per version. As it should be included in Python 3.4 (but unsure what vendor package managers do ...), the following is cited in referenced doc:
python3 -m pip install SomePackage # default Python 3
python3.4 -m pip install SomePackage # specifically Python 3.4
Python3 and Python2 have very separate package definitions. When you have a package installed for python2, it is definitely not installed for python3. Typically, python has a version of pip installed for each version of python. Such as pip3.3 or pip3.4 for python3 and pip 2.6 or pip 2.7 for python 2. If you're trying to use a package for python 2 it will not register as installed for python 3.

Which version of Pip to use with my Python installs?

Being new to Python, I'd love to clear up a few points that I couldn't get from reading various articles and tutorials.
After using Homebrew to install Python3, I noticed that it had installed both Python3 and Python3.4. I was also a little surprised that there are now three versions of pip on my machine too; pip, pip3 and pip3.4.
I created a new virtualenv and told it to use Python3, using the following command:
virtualenv -p /usr/local/bin/python3 mysite
I was also surprised that the version of Python that it installed in my VM was 3.4.
Is it safe to have these multiple version of Python and Pip hanging around on my machine?
Am I right to assume that I should take extra care to use the matching version of pip with Python, for example, pip3.4 with Python3.4?
Yes, it is safe. Python uses this naming like python3.4, python3.5 etc to differentiate between releases. python3 is a symbolic link to the current python3.x version. Pip follows the same convention.
If you're using python3.4 explicitly, you should be using pip3.4 specifically as well. Otherwise, just use python3 and pip3. For Python 2, you can simply use python (which, unless you installed the Homebrew version as well), will be the system Python), and ditto for pip. python2.7 and pip2.7 may also work.
In general, to find out which Python version goes with which pip you're using, try:
pip --version
and you'll see the Python included in the result.
No need to worried about if you have multiple version of Python and Pip installed. just check your version by writing in terminal :
$ brew info python
or to check the version of pip write in terminal :
$ brew info pip
and make sure you have updated your both pip and python version (write in terminal $ brew upgrade pip/python)
and other way to install python is go to https://www.python.org/downloads/ and choose as your requirement, there is two version available 2.7.9 & 3.4.3 ,
after installing python write in terminal $ python -V to check its version :) Hope it will help :)

Does IPython support python version 3.2.3? If not, why?

I am currently working on a project that makes use of Python 3.2.3 and thought to do some tests of my code in IPython but it seems that IPython does not support the version of python I am using.
I get the following ImportError when trying to run Ipython on my Ubuntu machine.
ImportError: IPython requires Python version 2.7 or 3.3 or above.
You can find some discussion about dropping 2.6 and 3.2 support here. One of the main reasons was that 3.2 does not support 2.x-style unicode strings - u"I love IPython!", while 3.3 and above do. This change made it possible to support 2.7 and 3.3+ in a single codebase.
Quickstart:
IPython requires Python 2.7 or ≥ 3.3.
If you need to use Python 2.6 or 3.2, you can find IPython 1.0 here.
PS:
The deadsnakes PPA has packages for old and new python versions:
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install python3.3

Python can't get requests installed on Ubuntu for Python 2.7

All I want to do is run a Python script that requires Python 2.7 & Requests on my Ubuntu 10.04 EC2 box.
I installed Python 2.7, no problem. "python" by itself still points to python 2.6, which is very annoying, b/c I'm not sure how ubuntu will freak if I change the symlink /usr/bin/python to point to 2.7.
I followed the (carefully buried) install instructions for pip (at http://www.pip-installer.org/en/latest/index.html, and which are WAY too hard to find if they aren't the ABSOLUTE FIRST command on the "install pip" page)
So, the real problem here is that pip install requests completes successfully, but only installs for python 2.6, not 2.7. The pip usage instructions say nothing about how to install a package for a specific version of python.
How do I do this?
I just want to run my python script that requires 2.7 + requests.
First install pip for your 2.7 distribution using easy_install (easy_install should definitely be included with your 2.7 distribution):
easy_install-2.7 -U pip
Then install what you need:
pip-2.7 install requests
Then you can run code with python2.7 instead of python.
Yeah it would be a bad idea to change the link pointing to which python version. Instead, can you change the shebang to say #!/usr/bin/env python2.7 instead of #!/usr/bin/env python ?
Though python2.7 /path/to/pip install requests might work; you should install pip for python2.7 separately instead.
If you don't use virtualenv then invoke pip as pip-2.7 (the command is available if you install pip for python2.7).
Follow installation instructions which is the first item in the table of contents. Substitute python with python2.7 in the instructions.

Categories

Resources