简体   繁体   English

Python脚本在pm2中抛出模块未找到错误但在cmd中有效

[英]Python script throws module not found error in pm2 but works in cmd

I want to demonise a python script with pm2 that worked before.我想用以前工作的 pm2 妖魔化一个 python 脚本。 I've created a venv with Python 3.6.8.我用 Python 3.6.8 创建了一个 venv。 I installed all modules that are required and tryed the script via console, which works.我安装了所有需要的模块并通过控制台尝试了脚本,它可以工作。 But if I start the module via pm2, I get an ModuleNotFound Error:但是如果我通过 pm2 启动模块,我会收到 ModuleNotFound 错误:

在此处输入图像描述

For all the other 23 scripts it worked as well with pm2.对于所有其他 23 个脚本,它也适用于 pm2。 The venv Python version is 3.6.8, the same as the version from the other venv where it was running before. venv Python 版本是 3.6.8,与之前运行的其他 venv 的版本相同。

Has someone encountered similar behaviour and can give me some suggestions on what I could try to solve the issue?有人遇到过类似的行为,可以给我一些关于我可以尝试解决问题的建议吗? Reinstalling the module doesn't help.重新安装模块没有帮助。

You should specified the absolute path of your virtual environment您应该指定虚拟环境的绝对路径

pm2 start 18 --interpreter /path/to/your/.venv/bin/python3

Also remember to check whether is the package exists:还要记得检查包是否存在:

/path/to/your/.venv/bin/python3 -m pip list

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

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