I would like to install graph tool on ubuntu. Therefore I want to make the default version of python to 3.7 instead of 2.7 because my compiler give me the error, that the python interpreter is to old to run the configure.
So do u know an solution?
Thanks a lot
If you need to execute Python3
when you run the python
command, the easiest way to do it is create an alias like this:
alias python=python3
But you don't need to mess with it, maybe you can launch the configurations and run programs with python3
command instead of python
.
python3 file.py
或者将#!/usr/bin/python3
添加到代码的第一行以使用 python 3 自动运行它。
I'll recommend not using aliases nor changing defaults. Those things have a way of coming back to bite you later on.
By your description, you said that the tool said the interpreter was too old. I'll guess that it needs a python3 interpreter. So what you should do is a simple sudo apt install python3
and use python3
instead of python
when running the code from the terminal.
Example:
Instead of python manage.py runserver
Do... python3 manage.py runserver
List all the installed versions of Python 3: ls /usr/bin/python3*
Add Python 3.7 to the alternatives list and change its priority: sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 1
Change the default version of Python by using following command:
sudo update-alternatives --config python
Type the number of the version you wish to set as default and confirm with enter.
python -V
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.