Python Virtualenv似乎也无法找到模块,即使已经安装了它们

发布于 2025-01-27 22:15:00 字数 1578 浏览 2 评论 0原文

我正在尝试在我的网站上运行Python应用程序,因此我为所有包装创建了一个虚拟环境,并且已经正确安装了所有我需要的软件包。当我检查到安装软件包的文件路径时,它们都指向正确的路径,当我到达我指向的site-packages文件时,它们都在那里。

但是,

每当我尝试运行我的应用程序时,我都会知道:

    stdin: is not a tty
Traceback (most recent call last):
  File "/opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/wsgi-loader.py", line 369, in <module>
    app_module = load_app()
  File "/opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/wsgi-loader.py", line 76, in load_app
    return imp.load_source('passenger_wsgi', startup_file)
  File "/home/dsmproto/testblockchain/passenger_wsgi.py", line 1, in <module>
    import main as application
  File "/home/dsmproto/testblockchain/main.py", line 2, in <module>
    from wallet import wallet
  File "/home/dsmproto/testblockchain/wallet.py", line 1, in <module>
    from Cryptodome.PublicKey import RSA
ImportError: No module named Cryptodome.PublicKey

我知道该模块在那里,但是由于某种原因,它仍然说没有模块。

我可以在SSH中使用命令来检查我的应用程序在哪里寻找模块吗?

我安装的所有模块都正确安装了。此外,当我打开SSH并在终端运行Python命令时,他们能够无需任何问题就导入所有模块。

那么我的应用程序怎么找不到这些模块?有没有办法进行检查以确保他们在正确的位置看?

预先感谢您的帮助

编辑:

我在python上运行了一个脚本来查看sys.path并得到了:

    /opt/alt/python38/lib64/python38.zip
/opt/alt/python38/lib64/python3.8
/opt/alt/python38/lib64/python3.8/lib-dynload
/home/dsmproto/virtualenv/testblockchain/3.8/lib64/python3.8/site-packages
/home/dsmproto/virtualenv/testblockchain/3.8/lib/python3.8/site-packages

这些是安装我的软件包的正确文件夹,但是当我尝试运行时我的应用程序仍然说它找不到它们。

I am trying to run my python app on my website, and so I've created a virtual environment for all of the packages, and I've correctly installed all of the packages I need. When I check on the file path to my installed packages, they are all pointing to the correct path, and when I got to my site-packages file that they point to, they are all there.

However,

Every time I try to run my app, I get this:

    stdin: is not a tty
Traceback (most recent call last):
  File "/opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/wsgi-loader.py", line 369, in <module>
    app_module = load_app()
  File "/opt/cpanel/ea-ruby24/root/usr/share/passenger/helper-scripts/wsgi-loader.py", line 76, in load_app
    return imp.load_source('passenger_wsgi', startup_file)
  File "/home/dsmproto/testblockchain/passenger_wsgi.py", line 1, in <module>
    import main as application
  File "/home/dsmproto/testblockchain/main.py", line 2, in <module>
    from wallet import wallet
  File "/home/dsmproto/testblockchain/wallet.py", line 1, in <module>
    from Cryptodome.PublicKey import RSA
ImportError: No module named Cryptodome.PublicKey

I know that the module is there, but for some reason it is still saying there's no module.

Is there a command I can use in my SSH to check where my app is looking for modules?

All of the modules I have installed are installed correctly. Furthermore, when I open the SSH and run python commands in the terminal, they are able to import all of the modules without any issues.

So how come my app can't find these modules? Is there a way to check to make sure they are looking in the right place?

Thanks in advance for the help

EDIT:

I ran a script in python to look at the sys.path and got this:

    /opt/alt/python38/lib64/python38.zip
/opt/alt/python38/lib64/python3.8
/opt/alt/python38/lib64/python3.8/lib-dynload
/home/dsmproto/virtualenv/testblockchain/3.8/lib64/python3.8/site-packages
/home/dsmproto/virtualenv/testblockchain/3.8/lib/python3.8/site-packages

Those are the correct folders that my packages are installed in, yet when I try to run my app, it still says it can't find them.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文