简体   繁体   中英

how to install python3.3 completely and remove python2.7 on Ubuntu12.04?

I have installed python3.3 with commands:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install python3.3

It works,but python2.7 installed in ubuntu by default still exiet.When I type "python",it show me the interactive shell of python2.7. I can use python3.3 by type "python3.3",but i can't import some library,such as gtk,Qt.but it works in 2.7.

Now I want to remove python2.7,it show me that it will free 247M,which beyond my expection.If I did it,any important library would be removed togeter?

How to use the Qt library with python3.3 instead of 2.7?

Thank you for answering!

Completely removing python 2.7 is not the best option, as it is default python version for ubuntu and you might end breaking some python-dependent utilities and programs.

Consider using virtual environment manager for different libraries management. I use pyenv for python versions management and virtualenvwrapper for python packages management.

For example running

export PATH=/path/to/python3
source /usr/local/bin/virtualenvwrapper.sh
mkvirtualenv test --no-site-packages

will make a clean virtual environment for you, where you can install any needed packages, sucha as Qt .

Firstly: do not remove python-2.7 and do not modify your existing python-2.7 installation in any way.

To use PyQt4 with python3, you will need to install the ubuntu packages for it that are specific to python3: which I believe is the python3-pyqt4 package. So, for a start, try:

sudo apt-get install python3-pyqt4

If that works, you should be able to run python3 to start up an interpreter, and then do from PyQt4 import QtCore to check that everything is working okay.

In general, each python installation will have its own set of libraries that are specific to either python2 or python3. So if you need other libraries for python3, you will have to check whether there are any "python3-xxx" ubuntu packages available for it.

you can download python3.3 from www.python.org

and run the following command:

rm -rf /usr/bin/python

ln -s /you_download_python3.3_path/bin/python /usr/bin/python

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM