简体   繁体   English

如何访问安装在虚拟环境中的软件包?

[英]How can I access packages installed in a virtual environment?

I've created and activated a virtual environment on my mac and I've installed a package into the environment successfully via pip.我已经在我的 Mac 上创建并激活了一个虚拟环境,并且我已经通过 pip 成功地将 package 安装到了环境中。 Now I'd like to write a basic python script that uses said package but it spawns a "ModuleNotFoundError:".现在我想编写一个基本的 python 脚本,该脚本使用上述 package 但它会产生一个“ModuleNotFoundError:”。 The virtual environment is activated while I run the code.在我运行代码时,虚拟环境被激活。 I'm using Sublime Text 3 if that's relevant.如果相关,我正在使用 Sublime Text 3。

Just figured it out.刚刚想通了。 Sublime Text doesn't access the active venv. Sublime Text 不访问活动的 venv。 I just have to type python3 myfile.py in the terminal and then the code works.我只需要在终端中输入 python3 myfile.py 然后代码就可以工作了。

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

相关问题 如何在所有已安装软件包都离线的情况下重新创建python虚拟环境? - How can I recreate a python virtual environment with all installed packages offline? 如何冻结仅在虚拟环境中安装的包? - How to freeze packages installed only in the virtual environment? 如何从 Python 虚拟环境中删除未使用的已安装包? - How do I remove unused installed packages from Python virtual environment? 如何将已安装的软件包移动到新创建的虚拟环境中? - How to move installed packages to a newly created virtual environment ? Python虚拟环境未列出已安装的软件包 - Python virtual environment lists no installed packages 在虚拟环境中找不到 pip 安装的包 - pip installed packages not found in virtual environment 将虚拟环境安装的包导入 Jupyter Notebook - Importing Virtual Environment Installed Packages into Jupyter Notebook 我可以在运行于Python 3的虚拟环境中使用Python 2软件包吗? - Can I use Python 2 packages in a virtual environment that runs on Python 3? 如何在虚拟环境中使用系统安装的python软件包? - How can I use a system installed python package within a virtual environment? 除非我在 windows 中使用 cmd 提示符安装它们,否则找不到安装在我的虚拟环境中的软件包 - Packages installed in my virtual environment arent found unless I install them using cmd prompt in windows
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM