Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrading python version on Bash on Ubuntu on Windows?

so I'm currently trying to upgrade the python version in the bash on ubuntu on windows subsystem. However from my understanding it is not easy to update python from the command line. Lastly, "where" exactly is my unix subsystem? For example, is there something like a unix portion on my file system, where I can just drag files into? Thanks

like image 796
information_interchange Avatar asked Jan 03 '23 22:01

information_interchange


2 Answers

It is an older question, however I had to do the same thing today (use python3.6 on my windows 10 laptop).

Press Windows + R (to open the run command dialog)
Type: bash + press Enter

You will get a new windows bash prompt window.

Type first lsb_release -a to check that you run the latest bash/ubuntu environment on your Windows Machine (might be ubuntu 14.04, while 16.04 is the current one).

raz@HOSTNAME:~/myPlayground$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.4 LTS
Release:        16.04
Codename:       xenial

If you are running an older version upgrade by running do-release-upgrade

raz@HOSTNAME:~/myPlayground$ sudo do-release-upgrade
[sudo] password for raz:
Checking for a new Ubuntu release
No new release found.

Add the PPA custom repository (the standard apt repos have only 3.5 for now)

raz@HOSTNAME:~/myPlayground$ sudo add-apt-repository ppa:jonathonf/python-3.6
 A plain backport of *just* Python 3.6. System extensions/Python libraries may or may not work.

Don't remove Python 3.5 from your system - it will break.
 More info: https://launchpad.net/~jonathonf/+archive/ubuntu/python-3.6
Press [ENTER] to continue or ctrl-c to cancel adding it

gpg: keyring `/tmp/tmp5vq72la1/secring.gpg' created
gpg: keyring `/tmp/tmp5vq72la1/pubring.gpg' created
gpg: requesting key F06FC659 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmp5vq72la1/trustdb.gpg: trustdb created
gpg: key F06FC659: public key "Launchpad PPA for J Fernyhough" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
OK

Update the apt information:

raz@HOSTNAME:~/myPlayground$ sudo apt-get update
Hit:1 http://archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB]
Get:3 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial InRelease [18.0 kB]
Get:4 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main amd64 Packages [4,760 B]
Get:5 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main Translation-en [2,128 B]
Get:6 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB]
Fetched 241 kB in 10s (22.2 kB/s)
Reading package lists... Done

Finally install python3.6:

raz@HOSTNAME:~/myPlayground$ sudo apt-get install python3.6
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libpython3.6-minimal libpython3.6-stdlib python3.6-minimal
Suggested packages:
  python3.6-venv python3.6-doc binfmt-support
The following NEW packages will be installed:
  libpython3.6-minimal libpython3.6-stdlib python3.6 python3.6-minimal
0 upgraded, 4 newly installed, 0 to remove and 3 not upgraded.
Need to get 4,505 kB of archives.
After this operation, 23.1 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

Get:1 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main amd64 libpython3.6-minimal amd64 3.6.5-5~16.04.york1 [574 kB]
Get:2 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main amd64 python3.6-minimal amd64 3.6.5-5~16.04.york1 [1,712 kB]
Get:3 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main amd64 libpython3.6-stdlib amd64 3.6.5-5~16.04.york1 [1,989 kB]
Get:4 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main amd64 python3.6 amd64 3.6.5-5~16.04.york1 [230 kB]
Fetched 4,505 kB in 4s (979 kB/s)
Selecting previously unselected package libpython3.6-minimal:amd64.
(Reading database ... 31944 files and directories currently installed.)
Preparing to unpack .../libpython3.6-minimal_3.6.5-5~16.04.york1_amd64.deb ...
Unpacking libpython3.6-minimal:amd64 (3.6.5-5~16.04.york1) ...
Selecting previously unselected package python3.6-minimal.
Preparing to unpack .../python3.6-minimal_3.6.5-5~16.04.york1_amd64.deb ...
Unpacking python3.6-minimal (3.6.5-5~16.04.york1) ...
Selecting previously unselected package libpython3.6-stdlib:amd64.
Preparing to unpack .../libpython3.6-stdlib_3.6.5-5~16.04.york1_amd64.deb ...
Unpacking libpython3.6-stdlib:amd64 (3.6.5-5~16.04.york1) ...
Selecting previously unselected package python3.6.
Preparing to unpack .../python3.6_3.6.5-5~16.04.york1_amd64.deb ...
Unpacking python3.6 (3.6.5-5~16.04.york1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for mime-support (3.59ubuntu1) ...
Setting up libpython3.6-minimal:amd64 (3.6.5-5~16.04.york1) ...
Setting up python3.6-minimal (3.6.5-5~16.04.york1) ...
Setting up libpython3.6-stdlib:amd64 (3.6.5-5~16.04.york1) ...
Setting up python3.6 (3.6.5-5~16.04.york1) ...
raz@HOSTNAME:~/myPlayground$

Check your python versions:

raz@HOSTNAME:~/myPlayground$ python -V
Python 2.7.12
raz@HOSTNAME:~/myPlayground$ python3 -V
Python 3.5.2
raz@HOSTNAME:~/myPlayground$ python3.6 -V
Python 3.6.5
like image 182
ionescu77 Avatar answered Jan 06 '23 11:01

ionescu77


You can search your 'Start Menu' for 'Bash' and get the app that will open a command prompt from within Ubuntu Linux (not Unix).

AFAIK you cannot drag and drop into this from Explorer.exe but you may be able to run a Linux file app that can do this with X11 installed.

Finally, from Bash on Ubuntu command line app, you can run 'sudo apt-get install python3' to get latest for Ubuntu.

like image 24
geedew Avatar answered Jan 06 '23 10:01

geedew