今天才发现,现在Ubuntu18.04已经将默认的Python更新到3.6.6版本了,很开心!
admin@jason-VirtualBox:~$ pip3 -V
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
admin@jason-VirtualBox:~$ pip3 install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 75kB/s
Installing collected packages: pip
Successfully installed pip-18.1
admin@jason-VirtualBox:~$ pip3 -V
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
ImportError: cannot import name 'main'
重启虚拟机
admin@jason-VirtualBox:~$ pip -V
pip 18.1 from /home/admin/.local/lib/python3.6/site-packages/pip (python 3.6)
admin@jason-VirtualBox:~$ pip3 -V
pip 18.1 from /home/admin/.local/lib/python3.6/site-packages/pip (python 3.6)
安装任意库都会提示权限不足
admin@jason-VirtualBox:~$ pip install robotframework
Collecting robotframework
Downloading https://files.pythonhosted.org/packages/95/b1/4faa12e1950b9fbd00060c112fa6f828c4f3998e9b2f8c570c22db10bc88/robotframework-3.0.4.tar.gz (443kB)
100% |████████████████████████████████| 450kB 25kB/s
Building wheels for collected packages: robotframework
Running setup.py bdist_wheel for robotframework ... done
Stored in directory: /home/admin/.cache/pip/wheels/8a/01/4a/fd9aef57cca0087d0bd5ceba5db39247ef375fdc4df5ebfb59
Successfully built robotframework
Installing collected packages: robotframework
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/lib/python3.6/dist-packages/robot'
Consider using the `--user` option or check the permissions.
解决方案:
在install 后面添加 --user参数
admin@jason-VirtualBox:~$ pip install --user robotframework
Collecting robotframework
Installing collected packages: robotframework
Successfully installed robotframework-3.0.4
但是我们平时安装的时候是可以不用添加--user
参数的呢?
难道是我们升级pip的方式不对?