Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I've got both Python2.7 and Python3.4 installed on my computer.

I've installed Numpy for both 2.7 and 3.4, but can't figure out how to specify the PYTHONPATH variable so that 2.7 uses Numpy2.7 and 3.4 uses Numpy3.4. Is there a Python3-specific path variable I can set?

share|improve this question
    
How did you install numpy? You shouldn't need to set PYTHONPATH at all if you've properly installed modules; they should already be in the default sys.path. –  Wooble Jul 31 '14 at 15:07
    
I used macports –  Megatron Jul 31 '14 at 15:09
    
when you use python 3 you will be using the numpy installed for python 3 and vice versa for python 2 unless you have screwed something up. –  Padraic Cunningham Jul 31 '14 at 17:27

1 Answer 1

up vote 0 down vote accepted

As @Wooble said, you shouldn't need to set PYTHONPATH at all if you've properly installed modules.

To verify whether you are picking up the right files, go to your shell, and there, run the following

$ python2.7

>>> import numpy

>>> numpy.version # This prints file path to numpy
<module 'numpy.version' from '/home/user/ENV/local/lib/python2.7/site-packages/numpy/version.pyc'>

>>> numpy.version.full_version
'1.8.1'

By using the above, you can ensure that you are using the correct versions.

share|improve this answer
    
How can I properly install the modules so that 2.7 and 3.4 seek them in different paths? –  Megatron Jul 31 '14 at 16:03
    
@Megatron I thought you already installed them? What happens if you run the commands I said in console? –  mu 無 Jul 31 '14 at 19:45
    
I get ImportError: No module named 'numpy' when I know the 3.4 is installed via macports. I'll have to check a bit more. –  Megatron Jul 31 '14 at 20:52
    
Found out I have multiple python 3.4 binaries. Solved. Thanks! –  Megatron Aug 1 '14 at 17:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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