How can I remove a version of Python in Ubuntu 12.04? - python-2.7

I have just installed Ubuntu 12.04 which comes with Python 2.7. I have installed Python 3.3, so now I have both versions. For example, if I type python in the terminal I get version 2.7 and if I type python3.3 I get that version.
I don't see why I would need 2 versions (?) so how do I uninstall Python 2.7? And if I do so, will the "python" command then point to Python 3.3?

VERY IMPORTANT EDIT
Removing an older version of python may be very dangerous and can cause trouble in your whole system! For your case instead of removing the older python you can simply use an alias in your terminal, so that when you type python it opens python3.3;
Here is the procedure, add this line:
alias python=python3
Into~/.bash_aliases or: ~/.bashrc
Btw I guess If you ask this question in AskUbuntu you may have a quicker/better response!

You should never remove the builtin Python in your Ubuntu distribution. Bad things will happen if you do.
It is highly recommended to use virtualenv to install other Python environments.
Here's a good Stackoverflow question that demonstrates how:
Is it possible to install another version of Python to Virtualenv?

Related

Easiest way to have Python 2 and 3 coexist on Mac OSX 10.8 with Anaconda installed

I am using python 2.7.10 with Anaconda 2.3.0, and I use the Anaconda IDE with sublime text 3 (is it a different Anaconda??).
However, for a course I'm taking we're required to use python 3.5.
I would like to keep python 2.7 on my computer, though. What would be the easiest way to have both versions coexist and be easily accessible through the terminal (through sublime would be great, but I'd be happy with managing it on the terminal for now)?
Also, I typically run conda update conda, and conda update anaconda on a regular basis to keep everything up to date. How would that work with different versions of python installed?
This sort of thing is actually what Anaconda is built for. Although the default Python version depends on the installer you used, Anaconda supports both versions. The easiest way is to create a new virtual environment. From the following link, use this conda command to build a Python 3 environment:
conda create -n py35 python=3.5 anaconda
That is if you need Python 3.5 with all the anaconda packages. You can either leave that blank if you just want a vanilla version of Python 3.5, or specify individual packages.
Once you do this, Python 3.5 will be available with the console command py35. You should definitely read the following link about how to manage environments. Really, you should read that whole tutorial.

New point of view: pip dealing with multiple Python versions, Canopy, Anaconda on Linux

Using pip with different Python version is a common problem, as I see when I search the Internet. There are a lot of answers around, also in this forum. However nobody seems to encounter the same problem that I have:
I use Canopy python most and it was installed first. Later I installed Anaconda. Now when I try to install a program with pip it always install it in Canopy (or refuse to install it because it is already installed in Canopy.
for example:
$ pip install ipython
gives:
Requirement already satisfied...
but there are no ipython in my Anaconda-folder, it is in the /Enthought/Canopy_64bit/... folder
How can I overcome this problem?
Both versions are 2.7 and even if one is 2.7.11 and the other 2.7.12, it did not work to distinguish between the two by this.
Maybe you can try the following.
Find where both pip-s reside (whereis pip, I have it on ~/anaconda2/bin), then cd to the pip directory of the python version you want, and execute it from there.
I manage with the help of J. Corson comment:
When you want to use a particular Python installation, activate the desired environment. In my chase
source /home/per/anaconda_ete/bin/activate
then using pip made the installation in the anaconda python and I could install ipython and other stuff there... fine, thanks!

How to select what version of Python Spyder will open on Ubuntu 16.04?

I have been struggling with multiple versions of Python on Ubuntu 16.04. I have versions 2.7 and 3.5. I have followed the steps from the Anaconda site as to how to switch from one environment to another with "source activate snakes". That works well when just looking at the default when calling python from the terminal, but when I attempt to open spyder IDE, no matter what other version is the default, it just opens on python 2.7.
Any ideas how this can be switched in a non permanent way, since I need both versions of Python?
Thanks in advance,
Do you have spyder3? I have spyder and spyder3. Depending on which of those spyders I'm opening the default python would be 2.7 for spyder and 3.5 for spyder3. I open spyders from terminal in ubuntu. That might not be the most reasonable solution, but it works.

too many pythons on linux

i recently started using python with xubuntu on virtualbox but i'm having problems. I want to be able to use numpy so i thought that apt-get install python-numpy would solve everything, but using the shell i kept getting No module named numpy. I used IDLE and it could find it. I also have IDLE (using Python-2.7), and again it could import numpy. Then i noticed that the shell had python 2.7.9, while the IDLEs had python 2.7.6.
Using
import sys
print sys.path
this if what i get from 2.7.9 (shell)
/usr/local/lib/python2.7/site-packages/setuptools-17.0-py2.7.egg
/usr/local/lib/python2.7/site-packages/Pillow-2.3.0-py2.7-linux-x86_64.egg
/usr/local/lib/python2.7/site-packages/mock-1.0.1-py2.7.egg
/usr/local/lib/python27.zip
/usr/local/lib/python2.7
/usr/local/lib/python2.7/plat-linux2
/usr/local/lib/python2.7/lib-tk
/usr/local/lib/python2.7/lib-old
/usr/local/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/site-packages
and from 2.7.6 (IDLE)
/home/alessandro
/usr/bin
/usr/lib/python2.7
/usr/lib/python2.7/plat-x86_64-linux-gnu
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/PILcompat
/usr/lib/python2.7/dist-packages/gtk-2.0
/usr/lib/pymodules/python2.7
/usr/lib/python2.7/dist-packages/ubuntu-sso-client
I understand that i have two versions of python installed and somehow i ended up installing packageg into only one of them (the 2.7.6).
I'd like to be able to use 2.7.9 both in the shell and in IDLE and also i'd like to install so that python 2.7.9 can see them.
I read that i can add paths to the python sys.path, but isn't there a more efficient/persistent way to do what i want?
PS: tell me if you need more informations
For my projects I usually create a virtualenv for each python version I need for the project at hand. I manage them using pip to install specific versions that I need. Moreover you should be able to choose the python path in your IDE. While I'm not using IDLE, I read here that apparently idle comes along with the python versions during install. So maybe your idle versions collide with each other. If you want to have only one python version at the time on your machine you might consider a simple remove and fresh install of your desired version. Again I would recommend pip over apt-get etc. Hope this is of help for you.
Worth to check PyDev, a plugin for Eclipse to work on python.
http://marketplace.eclipse.org/content/pydev-python-ide-eclipse , or http://pydev.org/.
This allows you to configure the python version for different project's.
I have some project's with python 2.7 and others with 3.4.
it's checks the whole system in search for the PYTHONPATH to use!

Python version settings

I work on Ubuntu with Wingware Python IDE. The version, which we use by our projects is 2.7.X
This morning I updated the IDE, and it became a version >3.x.x
Now I want to install the old version 2.7.3, after I read TFM and try to define PYTHONPATH, I check my Python version on Ubuntu with the command:
python --version
and got the answer 2.7.3. Now I can not understand, why I have version 3.x.x in Wingware and how exactly (the import file is not clear) I can change my version after setting Python manually described here
Actually: It depends on wingware, because I can execute Python 2.7.3 in IPython and in console.
EDIT: I solved this problem myself. Here's my solution:
Following the manual:
Use Python - Executable
Use Interpreter to find right path (in my way it was /usr/bin/python3.2)
Go in /usr/bin/
Select right Python version. This path has ALL Python versions, you should just select the right one
I solve this problem someself. I post now my solution for other people.
After [manual][2] using:
Use Python - Executable
Use Interpreter to find right path (in my way it was /usr/bin/python3.2)
Go in /usr/bin/
Select right python version. This path has ALL Python version, you should just select the right one