[英]pyInstaller: ImportError: No module named 'praw'
I wanted to pack my script using pyInstaller. 我想使用pyInstaller打包我的脚本。 I run
pyinstaller file.py -F
, file is created successfully, but when running I get ImportError: No module named 'praw'
. 我运行
pyinstaller file.py -F
,成功创建了文件,但是运行时出现ImportError: No module named 'praw'
。 So I created new file containing only import praw
and run pyinstaller file.py -F --hidden-import=praw
but still get the same error when running. 所以我创建了一个仅包含
import praw
新文件,并运行pyinstaller file.py -F --hidden-import=praw
但是在运行时仍然出现相同的错误。
I was unable to find anything similar, most issues were solved by using --hidden-import
. 我找不到类似的东西,大多数问题都使用
--hidden-import
解决了。
Any ideas on how it can be solved? 关于如何解决的任何想法?
EDIT: 编辑:
praw
is installed inside virtual environment and running the script directly works as expected. praw
已安装在虚拟环境中,并且可以按预期直接运行脚本。
Seem pyinstaller run outside the virtualenv. 似乎pyinstaller在virtualenv外部运行。 Try switch to your virtualenv and run:
尝试切换到您的virtualenv并运行:
python -m PyInstaller -F file.py
I'll recommend to look at pyenv or virtualenv. 我建议看一下pyenv或virtualenv。 Activate these env's and install the
praw module
here. 激活这些环境并在此处安装
praw module
。 This should work. 这应该工作。
This command might help you out. 此命令可能会帮助您。 It installs the Praw module for you.
它会为您安装Praw模块。 Make sure you have pip installed!
确保您已安装点子!
pip install praw
I found a way to solve the issue: 我找到了解决问题的方法:
When using Python2.7, or starting the shell like python2
, we need to do 使用Python2.7或启动像
python2
这样的shell时,我们需要做
python2 -m pip install --user praw
to make sure they are linked during installation. 确保它们在安装过程中已链接。
Same idea for python3
shell. 对于
python3
shell同样的想法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.