Python Forum

Full Version: Upgrading to Python 3.5.2
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
In my install of Python on Ubuntu 16.04,I have Python 3.5.2. I want to upgrade to Python 3.6.2. It will not let me.

How do I do this?

I cannot do using any regular commands. Please note that I only want to update Python 3.5.2 to 3.6.2.

Any help appreciated.

Respectfully,

ErnestTBass
apt-get install python=3.6.2?
you can just install python3.6 and then make an alias in your .bashrc file to point to python3.6. However i am not sure of what bug version their repos are using. Its 3.6.X
~/.bashrc at end of file
 alias python3='python3.6'
apt-get install python=3.6.2?

Now by doing it this way, what happens to Python 3.5.2? I only want
Python 3.6.2, not Python 3.6.2 and Python 3.5.2.

Any help appreciated. Thanks in advance.

Respectfully,

ErnestTBass
I tried the code sequence shown in this link:

https://www.reddit.com/r/learnpython/com...on_352_in/

I substituted 3.6.2 for 3.6.0, and I used pyvenv instead of pyenv.

It still did not work. I created and went to the directory

mkdir myproject && cd myproject

and set the local python version to the oe in the virtual environment.

It still says when I type

python -V

python 3.5.2, not 3.6.2. What is wrong? I am confused and thought that I did this correctly.

Respectfully,

ErnestTBass
(Jan-04-2019, 07:18 PM)ErnestTBass Wrote: [ -> ]I substituted 3.6.2 for 3.6.0, and I used pyvenv instead of pyenv.
I think you mixing up stuff here because that make no sense,pyenv is great an let you install real Python version that become OS default Python version.
pyvenv/virtualenv and build in venv allow you to create virtual environments so we can isolate our project dependencies.

So how it look for when i install 3.7 on Mint,with pyenv.
# Update pyenv
mint@mint ~ $ pyenv update
 
# Look at what's available
mint@mint ~ $ pyenv install --list
Available versions:
....
3.6.6
  3.6.6rc1
  3.7.0
  3.7-dev
  3.8-dev
....
 
# Update needed
sudo apt-get update
sudo apt-get install libffi-dev
 
# install Python 3.7
mint@mint ~ $ pyenv install 3.7.0
Installing Python-3.7.0...
Installed Python-3.7.0 to /home/mint/.pyenv/versions/3.7.0
 
# Set python and pip to point to 3.7
mint@mint ~ $ pyenv global 3.7.0
mint@mint ~ $ python -V
Python 3.7.0
mint@mint ~ $ pip -V
pip 10.0.1 from /home/mint/.pyenv/versions/3.7.0/lib/python3.7/site-packages/pip (python 3.7)
mint@mint ~ $ 
# Finish
So at this point Python 3.7 is the main Python OS version,
i could easily switch safely to eg Anaconda if that's needed this is the strength of pyenv.
I have more in tutorial about setup.
I dont remember which default python was on ubuntu 16.04. But you can really mess up your system by removing the wrong python version. Simply removing the default python can make it a nightmare to undo. Ive done this before and the easiest solution was to just reinstall linux as i kept digging myself deeper in the rabbit hole. AKA Removing python is a bad idea on linux unless you installed it in addition to the default python version. Ever since i just install the latest python version and make an alias to it to.

When you install a python version you can see the path it installed to via sys.path
$ python3.6
Python 3.6.1 (default, Jun  8 2017, 06:36:16) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/local/lib/python36.zip', '/usr/local/lib/python3.6', '/usr/local/lib/python3.6/lib-dynload', '/usr/local/lib/python3.6/site-packages']
If you look in that directory
metulburr@ubuntu:/usr/local/lib$ ls
libpython3.6m.a  pkgconfig  python2.7  python3.5  python3.6  python3.7
metulburr@ubuntu:~$ ls /usr/lib | grep python
python2.7
python3
python3.5
python3.6
python3.7
When you install a new linux version it doesnt replace the old one but makes a new directory. All you have to do is update the alias to the version you want, or just call the python version you want. Ive added python 3.5, 3.6, and 3.7 so i can safely remove those without messing up my system. sudo apt-get autoremove python3.6 and then make an alias to python3 for python3.7. However it doesnt really do anything by removing it. In fact i have so many 3rd party libraries installed to 3.6 i purposely will not remove it. The same may or may not be true to you.