首页
注册
登录
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请
登录
推荐学习书目
›
Learn Python the Hard Way
Python Sites
›
PyPI
- Python Package Index
›
http://diveintopython.org/toc/index.html
›
Pocoo
值得关注的项目
›
PyPy
›
Celery
›
Jinja2
›
Read the Docs
›
gevent
›
pyenv
›
virtualenv
›
Stackless Python
›
Beautiful Soup
›
结巴中文分词
›
Green Unicorn
›
Sentry
›
Shovel
›
Pyflakes
›
pytest
Python 编程
›
pep8 Checker
Styles
›
PEP 8
›
Google Python Style Guide
›
Code Style from The Hitchhiker's Guide
V2EX
›
Python
怎么在使用 wsgi 时导入自定义的模块
zeyexe
·
2011-12-22 23:08:01 +08:00
· 4876 次点击
这是一个创建于 5012 天前的主题,其中的信息可能已经有所发展或是发生改变。
我在 apache + wsgi 中要导入一个自己写的模块,把模块放到 c:\python\lib 目录下,import mymodule 可以正常工作,但是把它放到工程目录 d:\project\ 下则出现 500 Internal Server Error。如果我想把模块放到工程目录下,而又不想把工程目录加到系统路径,请问应该怎么写 import?
模块
目录
wsgi
4 条回复
•
1970-01-01 08:00:00 +08:00
1
keakon
2011-12-22 23:32:41 +08:00
把想要的路径加入sys.path试试
2
zeyexe
OP
2011-12-22 23:56:46 +08:00
@
keakon
这样可以用,只是代码变成了
import sys
sys.path.append('D:/project/')
import module
好像不太整齐
3
ry_wang
2012-01-09 18:19:47 +08:00
如果用的mod_wsgi的话,请查询WSGIPythonPath参数用法
如果用的uWSGI的话,请查询pythonpath参数用法
4
lepture
2012-01-09 19:26:38 +08:00
python2.7+ 建议使用 site
关于
·
帮助文档
·
自助推广系统
·
博客
·
API
·
FAQ
·
实用小工具
·
1393 人在线
最高记录 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 22ms ·
UTC 17:05
·
PVG 01:05
·
LAX 10:05
·
JFK 13:05
Developed with
CodeLauncher
♥ Do have faith in what you're doing.
❯