0

Using the /usr/local/bin install for Python 2.6.7 to keep it separate from Python 2.6.1 (see Upgrade Python to 2.6 on Mac), my new 2.6.7 binary isn't finding my 2.6 modules when I try to run code. As far as I understood, 2.6.1 and 2.6.7 should share modules because both are 2.6 modules.

ImportError: No module named unicodecsv

If I want to use my new /usr/local/bin/python (2.6.7) to run my program with modules I pip installed while using 2.6.1, what crucial step am I missing? A path issue? Using /usr/bin/python still imports the module without an issue.

I've confirmed that /usr/local/bin/pip install unicodecsv (and pip-2.6 install) just tells me I already have what I need:

Requirement already up-to-date: unicodecsv in /Library/Python/2.6/site-packages
Community
  • 1
  • 1
kiminoa
  • 2,649
  • 3
  • 16
  • 17
  • What does running both of the Python's show, when run using eg: `python -c "import sys; print sys.path"` – Jon Clements Feb 20 '13 at 19:55
  • Oh yes, that's definitely where I've failed. The 2.6.7 path is missing `/Library/Python/2.6/site-packages` among other things. Forgive my ignorance, I'm still a raging Python newbie ... is `sys.path` the same as `PYTHONPATH`? – kiminoa Feb 20 '13 at 20:02
  • Have a look at http://stackoverflow.com/questions/11697517/sys-path-and-pythonpath-issues – Jon Clements Feb 20 '13 at 20:11
  • Modules playing nice now that I have PYTHONPATH set up properly. Thank you! – kiminoa Feb 20 '13 at 20:14

1 Answers1

0

Use python -c "import sys; print sys.path" on the well-behaved binary that knows where the modules are to get correct paths. (thank you, Jon Clements.)

Create or update the PYTHONPATH environment variable to capture these paths so that your new binary is searching the right places.

In bash, for example, just add it to .bash_profile: EXPORT PYTHONPATH=path:from:above:sys_path:inquiry

And then re-execute to activate: . ~/.bash_profile

Community
  • 1
  • 1
kiminoa
  • 2,649
  • 3
  • 16
  • 17