I had python 2.6.1 because it was old I decide to install python 3.3.2 but, when I type "python" in my mac it prints it is version 2.6.1 and when I type python3 it shows that this is 3.3.2. I installed django 1.6 but when I check, understand that it is installed for old version of python (python 2.6.1). I want to instal it for my python 3.3.2 what should I do? any way to uninstall python 2.6.1 and when I enter python in terminal it's version be 3.3.2? I have mac os 10.6.8
-
1Use virtualenv. Refer to this post for further details: stackoverflow.com/questions/17837723/django-virtualenv-layoutkarthikr– karthikr2013-11-27 19:42:02 +00:00Commented Nov 27, 2013 at 19:42
-
I think this thread is a little bit more correct.alko– alko2013-11-27 19:44:33 +00:00Commented Nov 27, 2013 at 19:44
-
I don't think OP wants to keep the old version, so those links might not be relevent...yuvi– yuvi2013-11-27 19:50:06 +00:00Commented Nov 27, 2013 at 19:50
-
yes, I really don't need to keep old version of python just want to replace new with old and set python3 as default version, I mean when I type python in terminal python 3.3.2 will be printsandra– sandra2013-11-27 19:59:44 +00:00Commented Nov 27, 2013 at 19:59
-
@sandra and no issues on osx caused by py 2.6 absence? I have harder times on ubuntu.alko– alko2013-11-27 20:02:20 +00:00Commented Nov 27, 2013 at 20:02
4 Answers
Use python3 to call python version 3 on the command line.
For projects you can use virtual environments:
$ python # this will be version 2
$ python3 -m venv myenv
$ source myenv/bin/activate
$ python # this will be version 3
where myenv will be the folder that hosts the libraries and binaries for that virtual environment. It will automcatically use the python version that was used to initialize this venv - in this case python3. This has the effect that once you activate the venv you can use python there and it will be version 3.
Comments
To install django for python3, you need to use pip3 instead of pip.
python defaults to python2. pip defaults to pip for python2. So, when you install pip using whatever package manager you have, you are essentially installing pip for python2.
To remove Python2: $sudo apt remove python
To install pip for python3:
$sudo apt install python3-pip
To install pip for python2:
$sudo apt install python-pip
Note: I am using apt package manager. You should use the package manager for your OS.