2017-08-10 5 views
1

次のエラーが発生しています。私は同じエラーで提供された他の回答を試みたが、何も動作していない。どんな助けもありがとう。Django Apache:ターゲットWSGIスクリプトをPythonモジュールとしてロードできません

Apacheのエラーログ:

[Thu Aug 10 19:51:22.397653 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] mod_wsgi (pid=10908): Target WSGI script '/home/sharan/myproject/proj_VivRx1/proj_VivRx1/wsgi.py' cannot be loaded as Python module. 
[Thu Aug 10 19:51:22.397731 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] mod_wsgi (pid=10908): Exception occurred processing WSGI script '/home/sharan/myproject/proj_VivRx1/proj_VivRx1/wsgi.py'. 
[Thu Aug 10 19:51:22.398589 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] Traceback (most recent call last): 
[Thu Aug 10 19:51:22.398657 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "/home/sharan/myproject/proj_VivRx1/proj_VivRx1/wsgi.py", line 16, in <module> 
[Thu Aug 10 19:51:22.398664 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215]  application = get_wsgi_application() 
[Thu Aug 10 19:51:22.398675 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "/home/sharan/myproject/myprojectenv/lib/python3.5/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application 
[Thu Aug 10 19:51:22.398680 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215]  django.setup(set_prefix=False) 
[Thu Aug 10 19:51:22.398689 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "/home/sharan/myproject/myprojectenv/lib/python3.5/site-packages/django/__init__.py", line 22, in setup 
[Thu Aug 10 19:51:22.398694 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215]  configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) 
[Thu Aug 10 19:51:22.398703 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "/home/sharan/myproject/myprojectenv/lib/python3.5/site-packages/django/conf/__init__.py", line 56, in __getattr__ 
[Thu Aug 10 19:51:22.398708 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215]  self._setup(name) 
[Thu Aug 10 19:51:22.398717 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "/home/sharan/myproject/myprojectenv/lib/python3.5/site-packages/django/conf/__init__.py", line 41, in _setup 
[Thu Aug 10 19:51:22.398722 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215]  self._wrapped = Settings(settings_module) 
[Thu Aug 10 19:51:22.398731 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "/home/sharan/myproject/myprojectenv/lib/python3.5/site-packages/django/conf/__init__.py", line 110, in __init__ 
[Thu Aug 10 19:51:22.398736 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215]  mod = importlib.import_module(self.SETTINGS_MODULE) 
[Thu Aug 10 19:51:22.398745 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "/home/sharan/myproject/myprojectenv/lib/python3.5/importlib/__init__.py", line 126, in import_module 
[Thu Aug 10 19:51:22.398749 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215]  return _bootstrap._gcd_import(name[level:], package, level) 
[Thu Aug 10 19:51:22.398758 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "<frozen importlib._bootstrap>", line 986, in _gcd_import 
[Thu Aug 10 19:51:22.398776 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "<frozen importlib._bootstrap>", line 969, in _find_and_load 
[Thu Aug 10 19:51:22.398786 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked 
[Thu Aug 10 19:51:22.398795 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed 
[Thu Aug 10 19:51:22.398864 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "<frozen importlib._bootstrap>", line 986, in _gcd_import 
[Thu Aug 10 19:51:22.398879 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "<frozen importlib._bootstrap>", line 969, in _find_and_load 
[Thu Aug 10 19:51:22.398889 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked 
[Thu Aug 10 19:51:22.398913 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] ImportError: No module named 'proj_VivRx1' 

のVirtualHostファイル(apache2の/サイト利用可能/ 000-は、default.conf)

ServerAdmin [email protected] 
DocumentRoot /home/sharan/myproject 

ErrorLog ${APACHE_LOG_DIR}/error.log 
CustomLog ${APACHE_LOG_DIR}/access.log combined 

Alias /static /home/sharan/myproject/proj_VivRx1/app_match/static 
<Directory /home/sharan/myproject/proj_VivRx1/app_match/static> 
    Require all granted 
</Directory> 

<Directory /home/sharan/myproject/proj_VivRx1/proj_VivRx1> 
    <Files wsgi.py> 
     Require all granted 
    </Files> 
</Directory> 

<Directory /home/sharan/myproject/proj_VivRx1/proj_VivRx1> 
    Require all granted 
</Directory> 

<Directory /home/sharan/myproject/proj_VivRx1> 
    Require all granted 
</Directory> 

<Directory /home/sharan/myproject/myprojectenv> 
    Require all granted 
</Directory> 

WSGIDaemonProcess myproject python-path=/home/sharan/myprojects python-home=/home/sharan/myproject/myprojectenv 
WSGIProcessGroup myproject 
WSGIScriptAlias//home/sharan/myproject/proj_VivRx1/proj_VivRx1/wsgi.py 

WSGIファイル(/ホーム/シャラン/ myproject/proj_VivRx1/proj_VivRx1/wsgi.py):

import os,sys 
sys.path.append('/home/sharan/myproject/myprojectenv/lib/python3.5/site-packages') 
sys.path.append('/home/sharan/myproject/proj_VivRx1') 

from django.core.wsgi import get_wsgi_application 



path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 
if path not in sys.path: 
    sys.path.append(path) 

os.environ["DJANGO_SETTINGS_MODULE"] = "{{ project_name }}.settings" 

application = get_wsgi_application() 

私は場所で遊んでみました。また、アクセス許可はチェックされていますが、使用されません。 Apacheのバージョンは2.4.18です。

答えて

0

Apacheディレクティブのpython-pathパラメータにプロジェクトパス(/home/sharan/myproject/proj_VivRx1)を追加する必要があります。

+0

これはうまくいった。ありがとうございます – Sharan

0

*

[Thu Aug 10 19:51:22.397653 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] mod_wsgi (pid=10908): Target WSGI script '/home/sharan/myproject/proj_VivRx1/proj_VivRx1/wsgi.py' cannot be loaded as Python module. 
[Thu Aug 10 19:51:22.397731 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] mod_wsgi (pid=10908): Exception occurred processing WSGI script '/home/sharan/myproject/proj_VivRx1/proj_VivRx1/wsgi.py'. 
[Thu Aug 10 19:51:22.398589 2017] [wsgi:error] [pid 10908:tid 3048807232] [remote 10.0.2.15:12215] Traceback (most recent call last): 

はあなたのディレクトリ構造が台無しにされています。あなたのwsgiファイルが置かれているディレクトリのミックスマッチがあります。/home/sharan/myproject/proj_VivRx1/proj_VivRx1/wsgi.pyです。仮想ホストがそれを探すために設定されています...または/ home/sharanです。 /myproject/proj_VivRx1/wsgi.py?

ほとんどの場合、あなたのwsgiファイルがある正しい場所を指すようにフォルダパスを調整する必要があります。

+0

ありがとうございます。ありがとうございました – Sharan

関連する問題