Windows 无法执行 python exe 但可以在 pycharm 上执行 pythoncode
Windows cant excecute python exe but can execute pythoncode on pycharm
在 windows 命令提示符下执行时(使用的命令:python filename.py)或传输代码时,我似乎无法获取代码 运行用 pyinstaller 执行。在这两种情况下,它都会给出错误代码:ModuleNotFoundError: No module named 'plyer。这是 奇数 因为我确实指定导入模块。
from plyer import notification #pip install plyer
import time
def notifyMe(title, message):
notification.notify(
title = title,
message = message,
app_icon = None,
timeout = 10,
)
if __name__ == '__main__':
while True:
notifyMe("TEST")
time.sleep(100)
我猜您安装了两个版本的 python; pycharm 使用一个版本,另一个在您的路径中配置(因为您 运行 python filename.py)。
您的 pip 可能配置为安装到 pycharm 使用的 python 实例,因此您可能需要指定在 cmd 提示符中使用的 python 实例.
检查一下是否有帮助:
Install a module using pip for specific python version
Did you verify that running the script via a cmd command actually uses
the exact same Python environment as the PyCharm project? Usually
PyCharm projects have their own virtual Python environment that
packages get installed to, and so any packages available there usually
aren't available outside of that environment - Random Davis
link 如果 pyinstaller 没有导入所有模块,这对我有帮助:https://www.youtube.com/watch?v=2gu5stlEtms&list=WL&index=1
在 windows 命令提示符下执行时(使用的命令:python filename.py)或传输代码时,我似乎无法获取代码 运行用 pyinstaller 执行。在这两种情况下,它都会给出错误代码:ModuleNotFoundError: No module named 'plyer。这是 奇数 因为我确实指定导入模块。
from plyer import notification #pip install plyer
import time
def notifyMe(title, message):
notification.notify(
title = title,
message = message,
app_icon = None,
timeout = 10,
)
if __name__ == '__main__':
while True:
notifyMe("TEST")
time.sleep(100)
我猜您安装了两个版本的 python; pycharm 使用一个版本,另一个在您的路径中配置(因为您 运行 python filename.py)。
您的 pip 可能配置为安装到 pycharm 使用的 python 实例,因此您可能需要指定在 cmd 提示符中使用的 python 实例.
检查一下是否有帮助:
Install a module using pip for specific python version
Did you verify that running the script via a cmd command actually uses the exact same Python environment as the PyCharm project? Usually PyCharm projects have their own virtual Python environment that packages get installed to, and so any packages available there usually aren't available outside of that environment - Random Davis
link 如果 pyinstaller 没有导入所有模块,这对我有帮助:https://www.youtube.com/watch?v=2gu5stlEtms&list=WL&index=1