Linux下pip变为用pip3使用python3解释器,查看pip3。输入python默认用python3解释器
https://blog.csdn.net/weixin_43296326/article/details/88671133hellopython@ubuntu:~$ sudo rm -rf /usr/bin/python(删除原本的python连接,输入python命令就会调用该位置的命令,从而使用python2解释器)[sudo] password for hellopython:h...
·
pip变为用pip3使用python3解释器,查看pip3。
能用代码说明一切就绝不BB。
hellopython@ubuntu:/usr/bin$ pip3 freeze
Command 'pip3' not found, but can be installed with:
sudo apt install python3-pip
hellopython@ubuntu:/usr/bin$ sudo apt install python3-pip
hellopython@ubuntu:/usr/bin$ pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
hellopython@ubuntu:/usr/bin$ pip3 install selenium
Successfully installed selenium-3.141.0 urllib3-1.25.7
hellopython@ubuntu:/usr/bin$ pip3 show selenium
Name: selenium
Version: 3.141.0
Summary: Python bindings for Selenium
Home-page: https://github.com/SeleniumHQ/selenium/
Author: UNKNOWN
Author-email: UNKNOWN
License: Apache 2.0
Location: /home/hellopython/.local/lib/python3.6/site-packages
Requires: urllib3
hellopython@ubuntu:/usr/bin$ whereis python3
python3: /usr/bin/python3.6 /usr/bin/python3.6m /usr/bin/python3 /usr/bin/python3.6-config /usr/bin/python3.6m-config /usr/lib/python3.6 /usr/lib/python3 /usr/lib/python3.7 /usr/lib/python3.8 /etc/python3.6 /etc/python3 /usr/local/lib/python3.6 /usr/include/python3.6 /usr/include/python3.6m /usr/share/python3 /usr/share/man/man1/python3.1.gz
hellopython@ubuntu:/usr/bin$ pip3 freeze
apturl==0.5.2
selenium==3.141.0
.......
pip3安装的模块是用python3解释器运行,pip就默认用python2解释器。
输入python默认用python3解释器:
https://blog.csdn.net/weixin_43296326/article/details/88671133
我建议按系统来的就好,没必要做下面修改,因为只要用python3或者pip3 就能使用python3解释器,否则就能用python2解释器,万一真用得上python2呢。如果你喜欢折腾,不要python2,全默认python3就按以下步骤来做吧:
hellopython@ubuntu:~$ sudo rm -rf /usr/bin/python
(输入python命令就会调用该位置的命令,从而使用python2解释器。所以要删除原本的python连接)
[sudo] password for hellopython:
hellopython@ubuntu:~$ python
Command 'python' not found, but can be installed with:
sudo apt install python3
sudo apt install python
sudo apt install python-minimal
You also have python3 installed, you can run 'python3' instead.
hellopython@ubuntu:~$ pip install selenium
bash: /home/hellopython/.local/bin/pip: /usr/bin/python: bad interpreter: No such file or directory
hellopython@ubuntu:/usr/local/bin$ sudo ln -s /usr/local/bin/python3 /usr/bin/python
**(为 /usr/local/bin/python3 创建软链接到 /usr/bin/python,以后输入pyhton命令使用/usr/bin/python就会调用/usr/local/bin/python3)**
hellopython@ubuntu:~$ python
Command 'python' not found。。。。。
(无效后重新删除链接如下)
hellopython@ubuntu:/usr/local/bin$ sudo rm -rf /usr/bin/python
hellopython@ubuntu:~$ which python
/usr/bin/python
hellopython@ubuntu:~$ which python3
/usr/bin/python3
hellopython@ubuntu:/usr/local/bin$ sudo ln -s /usr/bin/python3 /usr/bin/python
hellopython@ubuntu:/usr/local/bin$ python
Python 3.6.8 (default, Oct 7 2019, 12:59:55)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
hellopython@ubuntu:~/.local/bin$ pip2 freeze
Traceback (most recent call last):
File "/home/hellopython/.local/bin/pip2", line 7, in <module>
from pip._internal.main import main
ModuleNotFoundError: No module named 'pip._internal'
hellopython@ubuntu:~/.local/bin$ pip3 freeze
apturl==0.5.2
asn1crypto==0.24.0
Brlapi==0.6.6
certifi==2018.1.18
chardet==3.0.4
.......
更多推荐
所有评论(0)