我正在将博客从 Wordpress 迁移到 Octopress 。作为此过程的一部分,我使用了一个名为 exitwp 的工具。将所有 Wordpress 内容转换为 Markdown 文件。
我已按照 exitwp
设置说明进行操作并安装了所有要求。 Python 是使用 homebrew 安装的; Python 模块是通过 pip
安装的。我使用的是 OS X 10.9 的 Mac。
$ which python
/usr/bin/python
$ pip install --upgrade -r pip_requirements.txt
Requirement already up-to-date: html5lib==1.0b1 in /usr/local/lib/python2.7/site-packages (from -r pip_requirements.txt (line 1))
Requirement already up-to-date: beautifulsoup4==4.2.0 in /usr/local/lib/python2.7/site-packages (from -r pip_requirements.txt (line 2))
Requirement already up-to-date: PyYAML==3.10 in /usr/local/lib/python2.7/site-packages (from -r pip_requirements.txt (line 3))
Requirement already up-to-date: html2text==3.200.3 in /usr/local/lib/python2.7/site-packages (from -r pip_requirements.txt (line 4))
Requirement already up-to-date: six in /usr/local/lib/python2.7/site-packages (from html5lib==1.0b1->-r pip_requirements.txt (line 1))
$ pip show PyYAML
Name: PyYAML
Version: 3.10
Location: /usr/local/lib/python2.7/site-packages
Requires:
$ python -c "import sys; print sys.path"
['', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages']
当我运行 exitwp
时,出现以下错误:
$ cd ~/code/exitwp/
$ python exitwp.py
Traceback (most recent call last):
File "exitwp.py", line 10, in <module>
import yaml
ImportError: No module named yaml
我的想法是,这可能与 OS X 中预装的 Python 有关,而且我已经通过 homebrew
安装了较新版本的 Python。我对 Python 和 pip
不太有经验,所以在深入了解这个问题时遇到了一些问题。
如果有人能指出我正确的方向,我将不胜感激。
最佳答案
您的python
可执行文件在/System/Library/Frameworks...
中搜索模块。 pip
将模块安装到 /usr/local/lib/python2-7/site-packages
一个快速而肮脏的解决方案只需将 /usr/local/lib/python2.7/site-packages
添加到您的 PYTHONPATH:
PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH python exitwp.py
关于python - Exitwp 无法导入 PyYAML 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20173535/