简体   繁体   English

python venv 中的“ModuleNotFoundError”? 我肯定在 venv 中安装了模块

[英]'ModuleNotFoundError' in python venv? I definitely have the module installed in the venv

I am trying to use PIL in my project.我正在尝试在我的项目中使用 PIL。 I sourced my venv and then installed using pip3 install Pillow.我采购了我的 venv,然后使用 pip3 install Pillow 安装。 I verified that the module is in fact installed but yet I am still getting the error.我确认该模块确实已安装,但我仍然收到错误消息。

pip3 list                                                                      
Package    Version
---------- -------
asgiref    3.5.2
Django     4.1.1
Pillow     9.2.0
pip        22.2.2
setuptools 63.4.3
six        1.16.0
sqlparse   0.4.3
(env) mike@Mikes-MacBook-Air test_app % /Users/mike/.pyenv/versions/3.9.2/bin/python /Users/mike/Desktop/bank_app/main.py
Traceback (most recent call last):
  File "/Users/mike/Desktop/bank_app/main.py", line 3, in <module>
    from PIL import Image, ImageTk
ModuleNotFoundError: No module named 'PIL'

I've tried reading through other posts with similar issues and saw someone mention that I could have an alias that is pointing to a different python location, could that be the issue?我尝试阅读其他有类似问题的帖子,看到有人提到我可能有一个指向不同 python 位置的别名,这可能是问题所在吗? How would I resolve that?我将如何解决?

Make sure your virtual environment is activated确保您的虚拟环境已激活

Command to activate virtual environment in linux an macOS:-在 linux 和 macOS 中激活虚拟环境的命令:-

source venv_name/bin/activate

Command to activate virtual environment in windows:-在 windows 中激活虚拟环境的命令:-

venv_name\Scripts\activate

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 venv 找不到 python 库,即使我确实安装了它 - venv cannot find python library even though I definitely have it installed 在 venv 中导入已安装的模块时出现 ModuleNotFoundError - ModuleNotFoundError when importing installed module in venv Python venv ModuleNotFoundError - Python venv ModuleNotFoundError 为什么 python 说我“没有名为 venv 的模块”? - Why is python saying I have "no module named venv"? Python venv 模块未找到 - Python venv module not found ModuleNotFoundError:没有名为“wtforms”的模块(VScode venv) - ModuleNotFoundError: No module named 'wtforms' (VScode venv) ModuleNotFoundError:在 vscode 中没有使用 venv 的模块名为“请求” - ModuleNotFoundError: No module named 'requests' using venv in vscode 找不到标准 Python 'venv' 模块 - Standard Python 'venv' module not found 在我的 VENV 中,PIP FREEZE 显示我安装了一个包,但是当我运行我的代码时,它说找不到模块 - When inside my VENV, PIP FREEZE shows I have a package installed but when I run my code, it says module not found Python package 位于 venv/lib/site-packages 文件夹中,并显示为安装在 PyCharm 但抛出 ModuleNotFoundError - Python package is in venv/lib/site-packages folder and shows as installed in PyCharm but throws ModuleNotFoundError
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM