これは私には理解できないほど奇妙なことです。
これは私のdjangoファイルディレクトリ階層の概要です
project/
apache/ django.wsgi
project/ __init__.py, settings.py, urls.py ..
services/
__init__.py
apis/
__init__.py
fparser.py
wservice.py
...
profile.py
したがって、開発サーバーやheroku(gunicorn)でもすべて正常に動作しますが、apache(localhost)では動作しません。
私がページを開いていたとき:
その上映
Exception Type: ImportError at /
Exception Value: cannot import name website_feed_address
これwebsite_feed_address
はprofile.pyにありimport error
ます。fparser.py
どうすれば修正できますか?
編集:
django.wsgi
import os, sys
sys.path.append('d:/code/projects-dev/project')
os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
質問で上記のプロジェクトディレクトリ階層はd:/code/projects-dev/
編集2
これらはapacheログエラーです
[Sun Jul 08 23:14:04 2012] [notice] Parent: Received restart signal -- Restarting the server.
httpd.exe: Could not reliably determine the server's fully qualified domain name, using 124.123.136.220 for ServerName
[Sun Jul 08 23:14:04 2012] [warn] mod_wsgi: Compiled for Python/2.7.
[Sun Jul 08 23:14:04 2012] [warn] mod_wsgi: Runtime using Python/2.7.2.
[Sun Jul 08 23:14:05 2012] [notice] Child 5912: Exit event signaled. Child process is ending.
[Sun Jul 08 23:14:05 2012] [warn] RSA server certificate CommonName (CN) `127.0.0.1' does NOT match server name!?
[Sun Jul 08 23:14:05 2012] [notice] Apache/2.2.22 (Win32) mod_wsgi/3.3 Python/2.7.2 mod_ssl/2.2.22 OpenSSL/0.9.8t configured -- resuming normal operations
[Sun Jul 08 23:14:05 2012] [notice] Server built: Jan 28 2012 11:16:39
[Sun Jul 08 23:14:05 2012] [notice] Parent: Created child process 2120
httpd.exe: Could not reliably determine the server's fully qualified domain name, using 124.123.136.220 for ServerName
[Sun Jul 08 23:14:05 2012] [warn] RSA server certificate CommonName (CN) `127.0.0.1' does NOT match server name!?
httpd.exe: Could not reliably determine the server's fully qualified domain name, using 124.123.136.220 for ServerName
[Sun Jul 08 23:14:05 2012] [warn] mod_wsgi: Compiled for Python/2.7.
[Sun Jul 08 23:14:05 2012] [warn] mod_wsgi: Runtime using Python/2.7.2.
[Sun Jul 08 23:14:05 2012] [warn] RSA server certificate CommonName (CN) `127.0.0.1' does NOT match server name!?
[Sun Jul 08 23:14:05 2012] [notice] Child 2120: Child process is running
[Sun Jul 08 23:14:06 2012] [notice] Child 2120: Acquired the start mutex.
[Sun Jul 08 23:14:06 2012] [notice] Child 5912: Released the start mutex
[Sun Jul 08 23:14:06 2012] [notice] Child 2120: Starting 64 worker threads.
[Sun Jul 08 23:14:06 2012] [notice] Child 2120: Starting thread to listen on port 443.
[Sun Jul 08 23:14:06 2012] [notice] Child 2120: Starting thread to listen on port 80.
[Sun Jul 08 23:14:07 2012] [notice] Child 5912: Terminating 126 threads that failed to exit.
[Sun Jul 08 23:14:07 2012] [notice] Child 5912: All worker threads have exited.
[Sun Jul 08 23:14:07 2012] [notice] Child 5912: Child process is exiting
編集3
これがprofile.py、fparser.pyの外観です
profile.py
いくつかの変数、ちょうどのようなタプルが含まれていますsettings.py
。website_feed_address
この場合、変数をインポートするだけです。
これはfparser.py
from profile import website_feed_address
import feedparser
class FParser(object):
def __init__(self):
self.pFeed = feedparser.parse(website_feed_address)
# rest of the code goes...
FParserクラスでwebsite_feed_addressをオブジェクト引数として使用せずに使用したいだけです。より良い方法はありますか?..または、このように使用できますか?