django - ImportError:没有名为“django_select2”的模块
问题描述
我正在尝试将我的 django 应用程序部署在pythonanywhere
. 我已经安装了应用程序所需的所有软件包。我还在django_select2
我的应用程序中使用可重用的应用程序。
首先,我激活虚拟环境并django_select2
通过以下命令安装:
$ pip install django_select2
当我执行以下命令时
$ pip freeze
cryptography==2.2.2
Django==2.0.7
django-appconf==1.0.2
django-select2==6.1.0
Flask==1.0.2
Flask-JWT==0.3.2
Flask-SQLAlchemy==2.3.2
furl==1.2
idna==2.7
如您所见django_select2
,它也在安装列表中。我还检查site-packages
了我的虚拟环境。还有django_select2
文件夹。
但是,当我运行我的应用程序时,它会ImportError: No module named 'django_select2'
在我的内部生成error.log
这是我的一部分error.log
2018-07-14 14:18:53,934: Error running WSGI application
2018-07-14 14:18:53,934: ImportError: No module named 'django_select2'
2018-07-14 14:18:53,934: File "/var/www/harunergul_pythonanywhere_com_wsgi.py", line 22, in <module>
2018-07-14 14:18:53,935: application = get_wsgi_application()
2018-07-14 14:18:53,935:
2018-07-14 14:18:53,935: File "/usr/local/lib/python3.5/dist-packages/django/core/wsgi.py", line 13, in get_wsgi_application
2018-07-14 14:18:53,935: django.setup(set_prefix=False)
2018-07-14 14:18:53,935:
2018-07-14 14:18:53,935: File "/usr/local/lib/python3.5/dist-packages/django/__init__.py", line 27, in setup
2018-07-14 14:18:53,935: apps.populate(settings.INSTALLED_APPS)
2018-07-14 14:18:53,935:
2018-07-14 14:18:53,935: File "/usr/local/lib/python3.5/dist-packages/django/apps/registry.py", line 85, in populate
2018-07-14 14:18:53,936: app_config = AppConfig.create(entry)
2018-07-14 14:18:53,936:
2018-07-14 14:18:53,936: File "/usr/local/lib/python3.5/dist-packages/django/apps/config.py", line 90, in create
2018-07-14 14:18:53,936: module = import_module(entry)
有什么建议么?我错过了什么?
解决方案
问题是在这种情况下应用程序没有使用虚拟环境。如果我们看下面的行,我们会看到/usr/local/...
。所以应用程序使用pythonanywhere.com
默认环境。
File "/usr/local/lib/python3.5/dist-packages/django/core/wsgi.py", line 13,
这意味着我们安装的任何东西virtualenv
对默认服务器都没有影响。在pythonanywhere.com
virtualenv 菜单中,请确保在此菜单中输入正确的路径信息。
推荐阅读
- python - 如何逐个遍历 Pandas 列并检测另一列的更改?
- python - 错误:没有为 ipython==7.17.0 找到匹配的分布
- c# - 对 ServicePointManager ServerCertificateValidationCallback 的困惑
- python - 通过装饰器从令牌中提取用户 ID
- c# - HTTP405: BAD METHOD - (XHR)Put :: 仅在服务器上
- c++ - 给定布尔变量 x、y 和 z 的真值,计算 x XOR y XOR z
- git - 如何将gitlab存储库设置为初始状态
- php - SQL查询返回从数组中选择作者的数据
- ios - 应用程序传输安全加载错误即使添加后
- macos - 检查网络摄像头是否已打开 (mac)