[英]Python: Cannot Run Script Outside of PyCharm (ImportError)
I am attempting to run a script that I have finished writing without having to launch PyCharm every time I run it. 我正在尝试运行已完成编写的脚本,而不必每次运行PyCharm都启动它。
However, I receive the following error when trying to run it from my command-line in Windows 10
: 但是,尝试从
Windows 10
命令行运行它时收到以下错误:
Traceback (most recent call last):
File "C:\Users\stuff\bot.py", line 5, in <module>
import irc.bot
ImportError: No module named irc.bot
My folder structure to get to irc.bot looks like: 我进入irc.bot的文件夹结构如下:
main folder
--venv
----lib
------site-packages
--------irc
----------bot.py
I'm fairly certain the issue is the virtual environment configuration, but I'm not sure how to get around that in a batch file to launch my script. 我相当确定问题出在虚拟环境配置中,但是我不确定如何在批处理文件中解决该问题以启动脚本。
为了让python识别模块,请首先使用位于以下位置的脚本进入虚拟环境:
venv\Scripts\activate
I've faced a similar issue. 我也遇到过类似的问题。
Upgrade the version of pip, wheel and setuptools in your virtualenv and afterwards try to install irc. 升级您的virtualenv中的pip,wheel和setuptools版本,然后尝试安装irc。
Hope that it works. 希望它能起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.