Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python 2.7 on System, PIP and Virtualenv still using 2.6 - How do I switch them to use 2.7

I am on MacOSx 10.6.8 and I have python 2.7 installed

python -v produces:

Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
dlopen("/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/readline.so", 2);
import readline # dynamically loaded from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/readline.so

I them run:

$ virtualenv venv

and then

$ . venv/bin/activate

and do a python -v

and I get:

Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
dlopen("/Users/nkhdev/venv/lib/python2.6/lib-dynload/readline.so", 2);
import readline # dynamically loaded from /Users/nkhdev/venv/lib/python2.6/lib-dynload/readline.so

Can someone tell me the steps to use have virtualenv create and use python 2.7 from my system? Or have virtualenv, use python 2.7 period. I don't care if the version is my system version.

like image 650
Nick Avatar asked Apr 07 '12 14:04

Nick


People also ask

How do you pip install for a specific version of Python?

How do I Install a Specific Version of a Python Package? To install a specific version of a Python package you can use pip: pip install YourPackage==YourVersion . For example, if you want to install an older version of Pandas you can do as follows: pip install pandas==1.1. 3 .


1 Answers

You probably used an existing, Apple-supplied version of easy_install to install pip et al. By default, easy_install is associated with a particular instance of Python, in this case, the Apple-supplied system Python 2.6. In general, when you install a new version of Python, you need to also install a new easy_install for it. Follow the instructions here for the Distribute package which provides easy_install, then use it to install pip and use that pip to install virtualenv.

like image 76
Ned Deily Avatar answered Sep 30 '22 09:09

Ned Deily