安装 colorama 时遇到问题

Trouble installing colorama

C:\Users\*****>pip install colorama
Collecting colorama
  Using cached colorama-0.4.3-py2.py3-none-any.whl (15 kB)
Installing collected packages: colorama
Successfully installed colorama-0.4.3

C:\Users\*****>python
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import colorama
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'colorama'
>>> exit()

C:\Users\*****>pip uninstall colorama
Found existing installation: colorama 0.4.3
Uninstalling colorama-0.4.3:
  Would remove:
    c:\users\rober\appdata\local\programs\python\python38-32\lib\site-packages\colorama-0.4.3.dist-info\*
    c:\users\rober\appdata\local\programs\python\python38-32\lib\site-packages\colorama\*
Proceed (y/n)? y
  Successfully uninstalled colorama-0.4.3

C:\Users\*****>pip install "C:\Users\rober\Downloads\colorama-0.4.3-py2.py3-none-any.whl"
Processing c:\users\rober\downloads\colorama-0.4.3-py2.py3-none-any.whl
Installing collected packages: colorama
Successfully installed colorama-0.4.3

C:\Users\*****>python
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import colorama
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'colorama'

我不知道该怎么办。你可以看到我下载文件的位置,我是运行最新的pip版本和python3.8。在网上一搜,我空手而归。

来自痕迹

启动 python 运行 python

的 64 位
C:\Users\*****>python
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

现在卸载时:

C:\Users\*****>pip uninstall colorama
Found existing installation: colorama 0.4.3
Uninstalling colorama-0.4.3:
  Would remove:
    c:\users\rober\appdata\local\programs\python\python38-32\lib\site-packages\colorama-0.4.3.dist-info\*
    c:\users\rober\appdata\local\programs\python\python38-32\lib\site-packages\colorama\*
Proceed (y/n)? y
  Successfully uninstalled colorama-0.4.3

它卸载到 32 位版本(注意 -32 后缀)。

所以pip可能指向32位版本。

可以使用 python 命令和 -m 选项来确保使用正确的安装来安装模块:

python -m pip install colorama

您可以使用 where pipwhere python,这将确认它们指向不同的 python 包。

如果你不使用它,我建议你卸载 32 位版本的 python 以避免进一步的混淆。

我不知道你是否还需要帮助,但我遇到了同样的问题并设法解决了。

我刚进入 cmd 并输入:

pip install colorama --user

它对我有用(编码新手和 python 所以我有 3.8.3 并且在几个 pip 安装中遇到了类似的问题)。