简体   繁体   English

即使我在虚拟环境中安装了模块,“没有模块命名”错误也可以在本地主机上正常运行

[英]'no module named' error even though I installed module in virtual environment and it works fine on localhost

I recently got a server through DigitalOcean and I'm playing around with a Flask App. 我最近通过DigitalOcean获得了一台服务器,并且正在使用Flask应用程序。

The app works perfectly fine on my computer when I run it locally. 当我在本地运行该应用程序时,该应用程序在我的计算机上可以正常运行。 But it doesn't work when hosted on DigitalOcean. 但是将其托管在DigitalOcean上时不起作用。 Both Virtual Environments are the same. 两个虚拟环境是相同的。

When I do 'pip freeze', the output is: 当我进行“点冻结”时,输出为:

coverage==4.0.3
dominate==2.1.16
Flask==0.10.1
Flask-Bootstrap==3.3.5.7
Flask-Login==0.3.2
Flask-SQLAlchemy==2.1
Flask-WTF==0.12
gunicorn==19.4.1
itsdangerous==0.24
Jinja2==2.8
MarkupSafe==0.23
SQLAlchemy==1.0.11
visitor==0.1.2
Werkzeug==0.11.3
wheel==0.24.0
WTForms==2.1

But I get an error when I look in Apache error log: 但是当我查看Apache错误日志时出现错误:

ImportError: No module named flask.ext.bootstrap ImportError:没有名为flask.ext.bootstrap的模块

I'm not sure why it can't find it. 我不确定为什么找不到它。 Like I said, it works fine on my computer when I run it locally. 就像我说的那样,当我在本地运行它时,它可以在我的计算机上正常工作。

I also tried 'from flask_bootstrap import Bootstrap' instead of 'from flask.ext.bootstrap import Bootstrap'. 我还尝试了“ from flask_bootstrap import Bootstrap”,而不是“ from flask.ext.bootstrap import Bootstrap”。 Both works locally, but neither work on DigitalOcean server. 两者均在本地工作,但在DigitalOcean服务器上均不工作。

Any suggestions? 有什么建议么?

Please check how you configured Apache. 请检查您如何配置Apache。 It's probably using the system default Python without your virtual env. 它可能使用没有虚拟环境的系统默认Python。

When making Flask Apps using digitalocean, this tutorial is a lot more up to date and simpler than the one I posted above: https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-14-04 当使用digitalocean制作Flask应用程序时,本教程比我上面发布的教程要更新得多,也更简单: https : //www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with -gunicorn-and-nginx-ubuntu-14-04

I did the process again, but this time using gunicorn and nginx and found the overall process a lot easier. 我再次进行了此过程,但是这次使用了gunicorn和nginx,发现整个过程要容易得多。

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

相关问题 没有名为 RPI 错误的模块(即使已安装) - No module named RPI error (even though it is installed) 即使我安装了它,也没有名为“Kivy”的模块 - No module named 'Kivy' even though I installed it ImportError:没有名为 qrcode 的模块,即使我安装了模块 - ImportError: No module named qrcode, even though i have the module installed 没有名为“setuptools”的模块,即使该模块已安装 - No module named 'setuptools', even though the module is installed “ModuleNotFoundError:即使安装了模块,也没有名为‘...’的模块 - "ModuleNotFoundError: No module named '…' even though module is installed 即使安装了名为MySQLdb的模块,也没有错误 - No module named MySQLdb error even though its installed Python 错误:即使已安装,也没有名为“matplotlib.pylot”的模块 - Python error: No module named 'matplotlib.pylot' even though it is installed 没有名为 X 的模块,即使我知道它已安装 - No module named X even though I know it is installed ModuleNotFoundError:没有名为“google.cloud”的模块,即使我安装了它 - ModuleNotFoundError: No module named 'google.cloud' even though I installed it 即使我安装了它,也没有名为“cv2”的模块 - No module named 'cv2' even though I installed it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM