ImportError:找不到名为 rfc822 的模块 pyramid python
当我尝试运行 pyramid 时
[~/env/MyStore]# ../bin/pserve development.ini
它会显示以下错误
File "/home/vretinfo/env/lib/python3.2/site-packages/Paste-1.7.5.1-py3.2.egg/paste/fileapp.py", line 14, in <module>
from paste.httpheaders import *
File "/home/vretinfo/env/lib/python3.2/site-packages/Paste-1.7.5.1-py3.2.egg/paste/httpheaders.py", line 140, in <module>
from rfc822 import formatdate, parsedate_tz, mktime_tz
ImportError: No module named rfc822
我该如何解决这个问题呢?
这是我安装时所做的步骤
$ mkdir opt
$ cd opt
$ wget http://python.org/ftp/python/3.2.3/Python-3.2.3.tgz
$ tar -xzf Python-3.2.3.tgz
$ cd Python-3.2.3
./configure --prefix=$HOME/opt/Python-3.2.3
$ make;
$ make install
$ cd ~
$ wget http://python-distribute.org/distribute_setup.py
$ pico distribute_setup.py
* change first line to opt/Python-3.2.3/python
$ opt/Python-3.2.3/bin/python3.2 distribute_setup.py
$ opt/Python-3.2.3/bin/easy_install virtualenv
$ opt/Python-3.2.3/bin/virtualenv --no-site-packages env
$ cd env
$ ./bin/pip install passlib
$ ./bin/pip install pyramid_beaker
$ ./bin/pip install pyramid_mailer
$ ./bin/pip install pyramid_mongodb
$ ./bin/pip install pyramid_jinja2
$ ./bin/pip install Werkzeug
$ ./bin/pip install pyramid
$ ./bin/pcreate -s pyramid_mongodb MyShop
$ cd MyShop
$ ../bin/python setup.py develop
$ ../bin/python setup.py test -q
好的,我在 pyramid 的文档上查了一下( http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/paste.html )。 在第三段中它提到:
“然而,所有 Pyramid 的脚手架都会生成 PasteDeploy 配置文件,以便为新开发者提供一种标准化的设置部署值的方法,并为新用户提供一种标准化的启动、停止和调试应用程序的方法。”
所以我对 development.ini 文件进行了修改,并替换了
[server:main]
use = egg:waitress#main
在 setup.py 中,我把 'waitress' 加入了需要的数组里
接下来的步骤,我完全删除了与 Paste 相关的所有内容,在 /home/vretinfo/env/ECommerce/ 目录下,
$ rm -rf Paste*;rm -rf paste*
之后,我再次尝试运行 test -q,这时得到了这个堆栈跟踪:
[~/env/ECommerce]# ../bin/python setup.py test -q
/home/vretinfo/opt/Python-3.2.3/lib/python3.2/distutils/dist.py:257: UserWarning: Unknown distribution option: 'paster_plugins'
warnings.warn(msg)
running test
Checking .pth file support in .
/home/vretinfo/env/ECommerce/../bin/python -E -c pass
Searching for Paste>=1.7.1
Reading http://pypi.python.org/simple/Paste/
Reading http://pythonpaste.org
Best match: Paste 1.7.5.1
Downloading http://pypi.python.org/packages/source/P/Paste/Paste-1.7.5.1.tar.gz#md5=7ea5fabed7dca48eb46dc613c4b6c4ed
Processing Paste-1.7.5.1.tar.gz
Writing /tmp/easy_install-q5h5rn/Paste-1.7.5.1/setup.cfg
Running Paste-1.7.5.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-q5h5rn/Paste-1.7.5.1/egg-dist-tmp-e3nvmj
warning: no previously-included files matching '*' found under directory 'docs/_build/_sources'
看起来 pyramid1.4 似乎需要 paste,可能有人对此有一些见解。
1 个回答
1
我通过IRC#pyramid的朋友们解决了这个问题。为了方便将来遇到相同问题的人,我把解决方案发在这里。我在Python3.2上测试过,现在可以正常工作了。
在项目文件夹中运行 ./bin/pcreate -s <...>
然后找到development.ini文件。
接下来,修改以下内容:
1. in the 1st line, rename [app:<Project>] to [app:main]
2. [server:main]
If it is egg:Paste#http, change it to
use = egg:waitress#main
3. remove [pipeline:main] and its section
在同一个文件夹中,修改setup.py文件:
1. requires = [....], add in waitress into the array, remove WebError from the array
2. remove paster_plugins=['pyramid']
最后,运行
$ ../bin/python setup.py develop
这样就不会安装Paste,也不会检查它是否存在。