所以我现在正试图在Windows子系统上的ubuntu上的bash中升级python版本。但是根据我的理解,从命令行更新python并不容易。最后,"其中"究竟是我的unix子系统?例如,我的文件系统上有类似unix部分的东西,我可以将文件拖入其中吗?感谢
答案 0 :(得分:4)
这是一个比较老的问题,但是我今天必须做同样的事情(在Windows 10笔记本电脑上使用python3.6)。
按 Windows + R (打开运行命令对话框)
输入:bash
+按 Enter
您将获得一个新的 windows bash提示窗口。
首先键入lsb_release -a
,以检查您是否在Windows计算机上运行了最新的bash / ubuntu环境(可能是ubuntu 14.04,而当前版本是16.04)。
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
如果您通过运行do-release-upgrade
raz@HOSTNAME:~/myPlayground$ sudo do-release-upgrade
[sudo] password for raz:
Checking for a new Ubuntu release
No new release found.
添加PPA自定义存储库(标准apt仓库目前只有3.5个)
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
更新apt信息:
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
最后安装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$
检查您的python版本:
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
答案 1 :(得分:1)
您可以搜索“开始”菜单'为了' Bash'并获得将在Ubuntu Linux(而不是Unix)中打开命令提示符的应用程序。
AFAIK你不能从Explorer.exe拖放到这个,但你可能能够运行一个Linux文件应用程序,可以安装X11。
最后,从Uashntu命令行应用程序上的Bash,您可以运行' sudo apt-get install python3'获取最新的Ubuntu。