无法在错误的 Python 版本中安装软件包
Trouble installing packages in the wrong Python version
我在 Python 中安装新软件包时遇到问题。我正在寻找 termcolor 包。我使用 apt:
安装它
sudo apt-get install python-termcolor
但是当我尝试在 Python 3.6 中使用它时,它一直告诉我没有安装。我检查了是否是,我得到了:
cris@Manaos:~$ dpkg -L python-termcolor
/.
/usr
/usr/share
/usr/share/pyshared
/usr/share/pyshared/termcolor-1.1.0.egg-info
/usr/share/pyshared/termcolor.py
/usr/share/doc
/usr/share/doc/python-termcolor
/usr/share/doc/python-termcolor/README.rst
/usr/share/doc/python-termcolor/copyright
/usr/share/doc/python-termcolor/changelog.Debian.gz
/usr/share/doc/python-termcolor/CHANGES.rst
/usr/lib
/usr/lib/python2.7
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/termcolor-1.1.0.egg-info
/usr/lib/python2.7/dist-packages/termcolor.py
所以我了解到该软件包已正确安装,但在 v2.7 中。如何在 v3.6 中安装它?
编辑: 我读过如果使用 pip 安装程序,我可以指定我希望安装哪个版本的 Python,比如使用pip3 安装 3.XX 中的包。但我试过了,它说它已正确安装,当我打开 Python 3.6 并尝试使用它时,仍然出现 ModuleNotFoundError。
EDIT2: 又查了一遍,发现用pip3在Python 3.5.3安装了termcolor包,但是怎么安装呢在 Python 3.6.1?
您需要指定您想要 python 3 版本。
sudo apt-get install python3-termcolor
我在 Python 中安装新软件包时遇到问题。我正在寻找 termcolor 包。我使用 apt:
安装它sudo apt-get install python-termcolor
但是当我尝试在 Python 3.6 中使用它时,它一直告诉我没有安装。我检查了是否是,我得到了:
cris@Manaos:~$ dpkg -L python-termcolor
/.
/usr
/usr/share
/usr/share/pyshared
/usr/share/pyshared/termcolor-1.1.0.egg-info
/usr/share/pyshared/termcolor.py
/usr/share/doc
/usr/share/doc/python-termcolor
/usr/share/doc/python-termcolor/README.rst
/usr/share/doc/python-termcolor/copyright
/usr/share/doc/python-termcolor/changelog.Debian.gz
/usr/share/doc/python-termcolor/CHANGES.rst
/usr/lib
/usr/lib/python2.7
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/termcolor-1.1.0.egg-info
/usr/lib/python2.7/dist-packages/termcolor.py
所以我了解到该软件包已正确安装,但在 v2.7 中。如何在 v3.6 中安装它?
编辑: 我读过如果使用 pip 安装程序,我可以指定我希望安装哪个版本的 Python,比如使用pip3 安装 3.XX 中的包。但我试过了,它说它已正确安装,当我打开 Python 3.6 并尝试使用它时,仍然出现 ModuleNotFoundError。
EDIT2: 又查了一遍,发现用pip3在Python 3.5.3安装了termcolor包,但是怎么安装呢在 Python 3.6.1?
您需要指定您想要 python 3 版本。
sudo apt-get install python3-termcolor