簡體   English   中英

無法在錯誤的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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM