2

I'm in the process of migrating a blog from Wordpress to Octopress. As a part of this process, I'm using a tool called exitwp to convert all Wordpress content to Markdown files.

I've followed the exitwp setup instructions and installed all the requirements. Python was installed using homebrew; the Python modules were installed with pip. I'm on a Mac with OS X 10.9.

$ 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']

When I run exitwp, I get the following error:

$ 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

My thoughts are that this might have something to do with Python coming pre-installed with OS X, and that I have installed a newer version of Python via homebrew. I'm not very experienced with Python and pip, so I'm having some problems getting to the bottom of this.

It would be greatly appreciated if anyone could point me in the right direction.

2
  • Could you run python -c "import sys; print sys.path" from your command line and post the output?
    – jazzpi
    Commented Nov 24, 2013 at 10:41
  • Thanks, @jazzpi. I've edited my question and added this information.
    – leifericf
    Commented Nov 24, 2013 at 10:50

1 Answer 1

4

Your python executable searches in /System/Library/Frameworks... for modules. pip installed your modules to /usr/local/lib/python2-7/site-packages though

A quick and dirty solution would be do simply add /usr/local/lib/python2.7/site-packages to your PYTHONPATH:

PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH python exitwp.py
3
  • Awesome, thanks! Worked like a charm. Could adding the path to my PATHONPATH have any adverse side effects? What would be "the slow and clean way" to fix it? :)
    – leifericf
    Commented Nov 24, 2013 at 11:06
  • 1
    @Leif: No, it shouldn't, since you're only setting the PYTHONPATH for the one command you're running (python exitwp.py). If you want it to be permanent, you'd have to export it. That could have side effects (being able to import modules from /usr/local/... somewhere else), but that would probably be positive, right?
    – jazzpi
    Commented Nov 24, 2013 at 12:15
  • Great, thanks again for the help and explanation. I will probably export it so that it's permanent, but I'll need to read up on that first; I need to understand what I'm doing first :)
    – leifericf
    Commented Nov 24, 2013 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.