在Ubuntu 16.04 LTS中从Python 3.5升级到Python 3.6后出现的问题
在我的Ubuntu16.04 LTS中,我按照这个步骤将Python 3.5(具体来说,是Python 3.5.2)升级到了3.6(具体来说,是Python 3.6.3) 在那篇文章中,我跳过了第一步,那就是 通过SSH登录并更新所有已安装的软件包在Ubuntu 16.04 LTS中从Python 3.5升级到Python 3.6后出现的问题,python,python-3.x,ubuntu,installation,pip,Python,Python 3.x,Ubuntu,Installation,Pip,在我的Ubuntu16.04 LTS中,我按照这个步骤将Python 3.5(具体来说,是Python 3.5.2)升级到了3.6(具体来说,是Python 3.6.3) 在那篇文章中,我跳过了第一步,那就是 通过SSH登录并更新所有已安装的软件包 首先,以root用户身份通过SSH登录Ubuntu 16.04 VPS sshroot@IP_Address-p端口号 并更新所有已安装的软件包 我遵循其余的步骤,在步骤4(方法1)和步骤5(方法2)之间,我选择了步骤4(方法1)。在所有的步骤中,我
首先,以root用户身份通过SSH登录Ubuntu 16.04 VPS
sshroot@IP_Address-p端口号
并更新所有已安装的软件包 我遵循其余的步骤,在步骤4(方法1)和步骤5(方法2)之间,我选择了步骤4(方法1)。在所有的步骤中,我甚至没有得到一个错误。现在,一般来说,我的机器没有任何副作用,但从Python的角度来看,我有以下问题:
Python3
,则会打开3.6.3,但如果我键入Python3.5
,则会打开3.5.2。那么,即使在升级之后,在我的机器中安装Python 3.5.2是否正常
pip3
安装任何Python包/库,因为它仍然只指向Python 3.5.2
virtualenv
),我如何将它指向Python3.6.3
Python3.5
(指向3.5.2)v/sPython3
(指向3.6.3)导入一些库时pip3 install numpy
会为Python 3.5.2安装numpy
,而不是为Python 3.6.3安装
Python3
打开Python3.6.3时,我甚至尝试了$Python3-m pip install numpy
命令来安装软件包,例如我的Python3.6.3的numpy
,但出现了以下错误:virtualenv
的情况下,如何将Jupyter笔记本指向Python 3.6.3?目前,这是我的Jupyter笔记本的输出,非常混乱:
1. from platform import python_version
2. print(python_version())
3.5.2
1. !python3 -V
Python 3.6.3
另外,在看到不同命令的上述输出后,我的系统现在是否混乱了(我的意思是从系统的角度来看)?我必须重新安装Ubuntu 16.04吗
问候语尝试从3.6版更新pip,可能会有所帮助:
python3-m pip安装-U pip
$ python3.5
Python 3.5.2 (default, Jul 17 2020, 14:04:10)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>>
$ python3
Python 3.6.3 (default, Jul 15 2020, 20:42:43)
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'
>>>
$ pip2 -V
pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)
$ pip -V
pip 20.1.1 from /home/milan/.local/lib/python3.5/site-packages/pip (python 3.5)
$ pip3 -V
pip 20.1.1 from /home/milan/.local/lib/python3.5/site-packages/pip (python 3.5)
Collecting numpy
Downloading https://files.pythonhosted.org/packages/22/e7/4b2bdddb99f5f631d8c1de259897c2b7d65dcfcc1e0a6fd17a7f62923500/numpy-1.19.1-cp36-cp36m-manylinux1_x86_64.whl (13.4MB)
100% |████████████████████████████████| 13.4MB 124kB/s
Installing collected packages: numpy
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python3.6/site-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/usr/local/lib/python3.6/site-packages/pip/req/req_set.py", line 784, in install
**kwargs
File "/usr/local/lib/python3.6/site-packages/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/usr/local/lib/python3.6/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/usr/local/lib/python3.6/site-packages/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/usr/local/lib/python3.6/site-packages/pip/wheel.py", line 316, in clobber
ensure_dir(destdir)
File "/usr/local/lib/python3.6/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/usr/local/lib/python3.6/os.py", line 220, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.6/site-packages/numpy'
You are using pip version 9.0.1, however version 20.2.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
1. from platform import python_version
2. print(python_version())
3.5.2
1. !python3 -V
Python 3.6.3
sudo ldconfig
python3 -m pip install --upgrade pip