我有一个托管所有Django应用程序的目录(C:\My_Projects).我想将此目录添加到我的PYTHONPATH所以我可以直接调用这些应用程序.
我尝试从Windows GUI()添加C:\My_Projects\;到我的Path变量My Computer > Properties > Advanced System Settings > Environment Variables.但它仍然没有读取coltrane模块并生成此错误:
错误:没有名为coltrane的模块
我想
import sys
sys.path.append("/home/me/mydir")
Run Code Online (Sandbox Code Playgroud)
将一个dir附加到我的pythonpath
如果我打印sys.path我的目录在那里.
然后我打开一个新命令,它就不存在了.
但不知何故,Python无法导入我保存在该目录中的模块.
我究竟做错了什么?
我读过.profile或.bash_profile就可以了.
我必须添加:
PATH="/Me//Documents/mydir:$PYTHONPATH"
export PATH
Run Code Online (Sandbox Code Playgroud)
为了使它工作?
我正在尝试在Django中开发一个示例项目,并在运行syncdb命令时收到错误.
这就是我的项目结构的样子:
/用户/ django_demo/godjango /预定:
manage.py
registration/
forms.py
views.py
models.py
urls.py
bookings/
settings.py
urls.py
Run Code Online (Sandbox Code Playgroud)
我的manage.py文件如下:
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bookings.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
Run Code Online (Sandbox Code Playgroud)
我的PYTHONPATH和DJANGO_SETTINGS_MODULE设置如下
$echo $DJANGO_SETTINGS_MODULE
bookings.settings
$ echo $PYTHONPATH
/Users/django_demo/godjango/bookings
Run Code Online (Sandbox Code Playgroud)
我的WSGI.py文件如下所示:
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bookings.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Run Code Online (Sandbox Code Playgroud)
当我运行python manage.py syncdb命令时,我收到以下错误.
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_from_command_line(sys.argv)
File "/Users/django_demo/godjango/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/Users/django_demo/godjango/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute …Run Code Online (Sandbox Code Playgroud) 我正在努力让pinax在WebFaction上工作并且遇到很多问题......
[Sun Feb 19 20:01:20 2012] [error] [client 127.0.0.1] mod_wsgi (pid=22796): Exception occurred processing WSGI script '/home/pawesome/webapps/qtsocial/myproject.wsgi'.
[Sun Feb 19 20:01:20 2012] [error] [client 127.0.0.1] Traceback (most recent call last):
[Sun Feb 19 20:01:20 2012] [error] [client 127.0.0.1] File "/home/pawesome/webapps/qtsocial/lib/python2.6/django/core/handlers/wsgi.py", line 250, in __call__
[Sun Feb 19 20:01:20 2012] [error] [client 127.0.0.1] self.load_middleware()
[Sun Feb 19 20:01:20 2012] [error] [client 127.0.0.1] File "/home/pawesome/webapps/qtsocial/lib/python2.6/django/core/handlers/base.py", line 39, in load_middleware
[Sun Feb 19 20:01:20 2012] [error] [client 127.0.0.1] for middleware_path in settings.MIDDLEWARE_CLASSES:
[Sun …Run Code Online (Sandbox Code Playgroud)