0
我在使用Python安裝新軟件包時遇到問題。我正在尋找包裝的termcolor包。我安裝了它使用apt:在錯誤的Python版本中安裝軟件包時遇到問題
sudo apt-get install python-termcolor
但是當我嘗試在Python 3.6使用它,它都跟我說不是安裝。我檢查是否是,我得到:
[email protected]:~$ 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中安裝它?
您應該改爲安裝'python3-termcolor'軟件包。這將正確安裝您所需的Python版本。我通常會推薦使用pip3。 – gabhijit