Python Forum

Full Version: How to make the python default language be 3.6 instead of 2.7
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all ! Now I am in Linux. On the terminal, if I type "python", python 2.7 appears. If I type "python3", python 3 appears. I should like very much that the default language be 3.6. What shall I type on the terminal in order to repair that ?
That option is provided on installation. You can change your environment variables to correct, or it might be better to reinstall, using

windows: https://python-forum.io/Thread-Basic-Par...nvironment
Linux: https://python-forum.io/Thread-Basic-Par...nvironment
pyenv is the best and safest way.
You need some set up as i have in tutorial here
@sylas with your track record of not getting stuff to work Wall ,read Setting up pyenv carefully.

When pyenv is setup,it's easy to use.
# Install
mint@mint ~ $ pyenv install 3.6.5
Downloading Python-3.6.5.tar.xz...
-> https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz
Installing Python-3.6.5...
Installed Python-3.6.5 to /home/mint/.pyenv/versions/3.6.5
  
# Set python and pip to point to 3.6.5
mint@mint ~ $ pyenv global 3.6.5
mint@mint ~ $ python -V
Python 3.6.5
mint@mint ~ $ pip -V
pip 9.0.1 from /home/mint/.pyenv/versions/3.6.5/lib/python3.6/site-packages (python 3.6)
# Finish
So now will python my_script.py and pip install something always use Python 3.6.5
There is never need for sudo pip install something or pip install --user something as pyenv has set user privileges.

It do not mess at all with system install of Python,and can easy back to local system.
mint@mint ~ $ pyenv local system
mint@mint ~ $ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
mint@mint ~ $ python3
Python 3.5.2 (default, Nov 17 2016, 17:05:23) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
 
Hi all! I am using Geany. Unfortunately the default python language is 2.7. With the same file, if I use the terminal directly, typing : python3 filename, no problem ! No error !
Here is the file:
hobbies = []
 
for i in range(3):
  hobby = input("Name a hobby: ")
  hobbies.append(hobby)
   
print(hobbies)
@snippsat I am on [Part-1]LinuxPython3. I have problem on #Install Requests
Error:
sylvain@sylvain-HP-Laptop-15-bw0xx:~$ sudo pip3 install requests Traceback (most recent call last): File "/usr/bin/pip3", line 9, in <module> from pip import main ImportError: cannot import name 'main'