简体   繁体   中英

importing the wx module in python

When I import the wx module in a python interpreter it works as expect. However, when I run a script (ie. test.py) with wx in the imports list, I need to write "python test.py" in order to run the script. If I try to execute "test.py" I get an import error saying there is no module named "wx". Why do I need to include the word python in my command?

PS the most helpful answer I found was "The Python used for the REPL is not the same as the Python the script is being run in. Print sys.executable to verify." but I don't understand what that means.

Write a two line script (named showexe.py for example):

import sys
print sys.executable

Run it both ways as showexe.py and python showexe.py . It will tell you if you're using the same executable in both cases. If not, then it'll depend on your operating system what you have to do to make the two run the same thing.

如果您使用#!/ usr / local / bin / python之类的脚本启动脚本(但使用python解释器的路径),则可以运行该脚本而无需在命令中包含python,例如bash脚本。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM