在我的Ubuntu16.04 LTS中,我按照这个Medium article将Python3.5(具体来说,Python3.5.2)升级到3.6(具体来说,Python3.6.3)
在那篇文章中,我跳过了第一步,那就是
Login via SSH and update all installed packages
First of all, login to your Ubuntu 16.04 VPS via SSH as user rootssh root@IP_Address -p Port_number
and update all installed packages
我遵循其余步骤,并在步骤4(方法1)和;第五步(方法2),我选择了第四步(方法1)。在所有的步骤中,我甚至没有得到一个错误。现在,一般来说,我的机器没有任何副作用,但从Python的角度来看,我有以下问题:
Python 3.5.2仍然存在于我的机器中:如果我键入Python3
,那么3.6.3将被打开,但是如果我键入Python3.5
,那么3.5.2将被打开。那么,即使在升级之后,在我的机器中安装Python 3.5.2是否正常
我无法使用pip3
安装任何Python包/库,因为它仍然只指向Python 3.5.2
当我打开Jupyter笔记本时,它仍然指向Python3.5.2(我没有使用^{
$ python -V
Python 2.7.12
$ python3 -V
Python 3.6.3
$ python3.5 -V
Python 3.5.2
$ which python
/usr/bin/python
$ which python3
/usr/local/bin/python3
$ which python3.5
/usr/bin/python3.5
Python3.5
(指向3.5.2)v/sPython3
(指向3.6.3)来import
一些库时$ 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'
>>>
pip
版本:$ 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)
因此,运行pip3 install numpy
会为Python3.5.2安装numpy
,而不是为Python3.6.3安装
Python3
打开Python 3.6.3时,我甚至尝试使用$ python3 -m pip install numpy
命令为我的Python 3.6.3安装包,例如numpy
,但出现以下错误: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.
那么,现在,我如何在我的Ubuntu 16.04 LTS中安装Python 3.6.3的包/库呢?有可能吗
如何在不安装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吗
确保新python二进制文件的正确pip版本
不,你的系统没有混乱,你不必重新安装Ubuntu
问候
相关问题 更多 >
编程相关推荐