1

I haven't tried yet out of fear I'll mess up more than I'll fix but I don't know if I can use PYTHONPATH to fix my problem. I've installed python 2.7.10 and python 3.4.2 on my Macbookpro. Python2.7 doesn't have problems, only 3.4 does. I'm afraid if I use PYTHONPATH to fix python3, it will affect python2.

Anyway, I've run:

sudo pip install blah2
sudo pip3 install blah3
pip freeze | grep blah2
blah2=2.12345
pip3 freeze | grep blah3
blah3=3.12345

and I can see I've installed the respective modules for python2 and python3 as pip freeze has shown. However, I keep getting errors when running scripts from cmd line for python 3.4 that say the module isn't found.

On further investigation using sys.path in my script, I can see python3 from cmd line is looking for modules at

/usr/local/lib/python3.4/site-packages

which doesn't have anything inside of it, whereas Idle for python 3.4 is looking at

/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages

which has tons of files in there.

I don't know why this got messed up in the first place or what I forgot to do to mess it up like this but how do I tell python 3.4 to look at the /Library location for modules?

The funny thing is both python2 and 3 were installed from tar/gzip files. I ran both using the

configure; make ;make install

command but for some reason python2 is fine but python3 isn't.

2
  • 2
    Have you tried out conda or pyenv instead? There are a handful of tools out there that manage this for you instead of you having to figure out all the weird tricks needed to make it work. Commented Dec 4, 2015 at 3:55
  • No, I didn't even know they existed. Thanks for the suggestion. Commented Dec 4, 2015 at 4:11

1 Answer 1

2

This may mean the pip3 is installing to that different path. Take a look at pip3 script and see where it is putting the package files. In my case the first line of it looks like this:

#!/opt/local/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4

Look if this is the path to the correct python3 binary. If it's not, you have two options: change this first line of pip3 to the path of your desired python3 binary, or just forget about it, use the pip directly with python3 command:

python3 -m pip install blah3

This should use the appropriate path when installing the package.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.