Python Forum
How to make the python default language be 3.6 instead of 2.7
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make the python default language be 3.6 instead of 2.7
#1
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 ?
Reply
#2
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
Reply
#3
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.
>>>
 
Reply
#4
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)
Reply
#5
@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'
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pip installs in a different python version and directory than the default 3.11 ao_tex_mal 9 3,344 Jun-20-2023, 02:55 PM
Last Post: snippsat
  Mac default python interpreter Viewpoint8455 2 909 Oct-13-2022, 06:25 AM
Last Post: perfringo
  logo language code into python aayushi98 2 65,250 Jan-26-2021, 09:02 PM
Last Post: Serafim
  set python default 3.0 tdwinfre 4 2,785 Nov-27-2020, 06:04 PM
Last Post: snippsat
  how to make a keyword arg w/o a default value? Skaperen 10 3,538 Jun-30-2020, 01:55 AM
Last Post: Skaperen
  How to see python default methods from inside mariolucas75 3 2,431 Jun-14-2020, 11:41 AM
Last Post: snippsat
  Inconsistency in Python programming language? newbieAuggie2019 31 11,356 Oct-06-2019, 03:21 PM
Last Post: adt
  Terms describing Python Programming language leodavinci1990 3 2,710 Aug-12-2019, 02:48 PM
Last Post: leodavinci1990
  How to get image from WolframAlpha by using Python language manhnt 1 2,686 Oct-27-2018, 02:07 PM
Last Post: Larz60+
  set 'default' cwd in python zealjeung 1 2,285 Aug-19-2018, 12:04 PM
Last Post: Windspar

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020