我的环境:
ubuntu server 16.04
apache2 (libapache2-mod-wsgi-py3)
django 1.11
python 3.6 (use conda env)
当我使用shell时,我写道:
import numpy
import numpy.core.multiarray
没关系
我的apache conf:
ServerName localhost:7080
ServerAdmin sdfsa@163.com
WSGIDaemonProcess comengine python-path=/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages
WSGIProcessGroup comengine
WSGIScriptAlias / /home/serverend/comengine/comengine/wsgi.py
<Directory /home/serverend/comengine/comengine>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error-comengine.log
CustomLog ${APACHE_LOG_DIR}/access-comengine.log combined
</VirtualHost>
但是,当我在我的django code.come错误中使用它时,就像这样:
[.867314 2017] [wsgi:error] [] Traceback (most recent call last):
[.867317 2017] [wsgi:error] [] File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/numpy/core/__init__.py", line 16, in < module>
[.867319 2017] [wsgi:error] [] from . import multiarray
[.867330 2017] [wsgi:error] [] ImportError: cannot import name 'multiarray'
[.867332 2017] [wsgi:error] []
[.867333 2017] [wsgi:error] [] During handling of the above exception, another exception occurred:
[.867335 2017] [wsgi:error] []
[.867337 2017] [wsgi:error] [] Traceback (most recent call last):
[.867339 2017] [wsgi:error] [] File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
[.867341 2017] [wsgi:error] [] response = get_response(request)
[.867343 2017] [wsgi:error] [] File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/core/handlers/base.py", line 172, in _get_response
[.867345 2017] [wsgi:error] [] resolver_match = resolver.resolve(request.path_info)
[.867347 2017] [wsgi:error] [] File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/urls/resolvers.py", line 362, in resolve
[.867349 2017] [wsgi:error] [] for pattern in self.url_patterns:
[.867351 2017] [wsgi:error] [] File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
[.867353 2017] [wsgi:error] [] res = instance.__dict__[self.name] = self.func(instance)
[.867354 2017] [wsgi:error] [] File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/urls/resolvers.py", line 405, in url_patterns
[.867357 2017] [wsgi:error] [] patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
[.867359 2017] [wsgi:error] [] File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
[.867361 2017] [wsgi:error] [] res = instance.__dict__[self.name] = self.func(instance)
[.867362 2017] [wsgi:error] [] File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
[.867364 2017] [wsgi:error] [] return import_module(self.urlconf_name)
[.867366 2017] [wsgi:error] [] File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
[.867368 2017] [wsgi:error] [] return _bootstrap._gcd_import(name[level:], package, level)
[.867370 2017] [wsgi:error] [] File "<frozen importlib._bootstrap>", line 986, in _gcd_import
[.867372 2017] [wsgi:error] [] File "<frozen importlib._bootstrap>", line 969, in _find_and_load
[.867374 2017] [wsgi:error] [] File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
[.867376 2017] [wsgi:error] [] File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
[.867377 2017] [wsgi:error] [] File "<frozen importlib._bootstrap_external>", line 665, in exec_module
[.867379 2017] [wsgi:error] [] File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
[.867384 2017] [wsgi:error] [] File "/home/serverend/comengine/comengine/urls.py", line 24, in <module>
[.867386 2017] [wsgi:error] [] url(r'^temrule/',include('templaterule.urls')),
[.867388 2017] [wsgi:error] [] File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/conf/urls/__init__.py", line 50, in include
[.867390 2017] [wsgi:error] [] urlconf_module = import_module(urlconf_module)
[.867392 2017] [wsgi:error] [] File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
[.867394 2017] [wsgi:error] [] return _bootstrap._gcd_import(name[level:], package, level)
[.867395 2017] [wsgi:error] [] File "<frozen importlib._bootstrap>", line 986, in _gcd_import
[.867397 2017] [wsgi:error] [] File "<frozen importlib._bootstrap>", line 969, in _find_and_load
[.867399 2017] [wsgi:error] [] File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
[.867401 2017] [wsgi:error] [] File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
[.867403 2017] [wsgi:error] [] File "<frozen importlib._bootstrap_external>", line 665, in exec_module
[.867405 2017] [wsgi:error] [] File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
[.867407 2017] [wsgi:error] [] File "/home/serverend/comengine/templaterule/urls.py", line 4, in <module>
[.867408 2017] [wsgi:error] [] from .views import ( get_compo_message,set_compomsg_file,set_compomsg_hand,get_param_message,get_errormsg,get_nodealmsg)
[.867410 2017] [wsgi:error] [] File "/home/serverend/comengine/templaterule/views.py", line 10, in <module>
[.867412 2017] [wsgi:error] [] import numpy as np
[.867414 2017] [wsgi:error] [] File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/numpy/__init__.py", line 146, in <module>
[.867416 2017] [wsgi:error] [] from . import add_newdocs
[.867418 2017] [wsgi:error] [] File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/numpy/add_newdocs.py", line 13, in <module>
[.867420 2017] [wsgi:error] [] from numpy.lib import add_newdoc
[.867422 2017] [wsgi:error] [] File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/numpy/lib/__init__.py", line 8, in <module>
[.867424 2017] [wsgi:error] [] from .type_check import *
[.867426 2017] [wsgi:error] [] File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/numpy/lib/type_check.py", line 11, in < module>
[.867428 2017] [wsgi:error] [] import numpy.core.numeric as _nx
[.867429 2017] [wsgi:error] [] File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/numpy/core/__init__.py", line 24, in < module>
[.867431 2017] [wsgi:error] [] raise ImportError(msg)
[.867435 2017] [wsgi:error] [] ImportError:
[.867437 2017] [wsgi:error] [] Importing the multiarray numpy extension module failed. Most
[.867439 2017] [wsgi:error] [] likely you are trying to import a failed build of numpy.
[.867441 2017] [wsgi:error] [] If you're working with a numpy git repo, try `git clean -xdf` (removes all
[.867443 2017] [wsgi:error] [] files not under version control). Otherwise reinstall numpy.
[.867449 2017] [wsgi:error] []
当我使用runserver
时一切都很好,但当我把我的django放在apache2上时,错误来了,为什么?我该如何解决?