Opened 8 years ago

Closed 8 years ago

#51655 closed defect (invalid)

py-numpy: Could not import numpy into python 2.7

Reported by: SmritiM84 Owned by: dh@…
Priority: Normal Milestone:
Component: ports Version: 2.3.4
Keywords: Cc: michaelld (Michael Dickens)
Port: py-numpy

Description

Following https://astrofrog.github.io/macports-python/ I installed Python, numpy, scipy and matplotlib and configured as directed in the link. But when I try to import numpy as a module I get the error "ImportError: No module named numpy". Instead if I try using py27-numpy, then I get a syntax error. While "which python returns "/Library/Frameworks/Python.framework/Versions/2.7/bin/python", "which numpy" and "which py27-numpy" give no output.

I am new to python and would greatly appreciate any help with this installation. I am using OSX 10.9.8. Macports seems to have installed py27-numpy @1.9.0_0, py27-numpy @1.11.0_0+gfortran (active), python2_select @0.0_1 (active), python27 @2.7.8_1, python27 @2.7.11_2 (active), python34 @3.4.4_1 (active) among others.

Change History (3)

comment:1 in reply to:  description ; Changed 8 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: michaelld@… added
Keywords: numpy python removed
Owner: changed from macports-tickets@… to dh@…
Port: python removed
Summary: Could not import numpy into python 2.7py-numpy: Could not import numpy into python 2.7

Replying to mahajan.smriti@…:

Following https://astrofrog.github.io/macports-python/ I installed Python, numpy, scipy and matplotlib and configured as directed in the link. But when I try to import numpy as a module I get the error "ImportError: No module named numpy". Instead if I try using py27-numpy, then I get a syntax error. While "which python returns "/Library/Frameworks/Python.framework/Versions/2.7/bin/python", "which numpy" and "which py27-numpy" give no output.

It is normal that which numpy and which py27-numpy would return no output, because there are no executables by those names. numpy is a python module, not an executable program.

/Library/Frameworks/Python.framework/Versions/2.7/bin/python is not MacPorts python; it's some other python you have installed outside of MacPorts. It will have no knowledge of python modules you install with MacPorts. To use MacPorts python modules, you must use MacPorts python, which is /opt/local/bin/python2.7. You can either run it by that absolute path, or if you want to be able to run it by just typing "python", then you can first run sudo port select python python27 and then close and reopen your terminal window.

comment:2 in reply to:  1 Changed 8 years ago by SmritiM84

Replying to ryandesign@…:

Replying to mahajan.smriti@…:

Following https://astrofrog.github.io/macports-python/ I installed Python, numpy, scipy and matplotlib and configured as directed in the link. But when I try to import numpy as a module I get the error "ImportError: No module named numpy". Instead if I try using py27-numpy, then I get a syntax error. While "which python returns "/Library/Frameworks/Python.framework/Versions/2.7/bin/python", "which numpy" and "which py27-numpy" give no output.

It is normal that which numpy and which py27-numpy would return no output, because there are no executables by those names. numpy is a python module, not an executable program.

/Library/Frameworks/Python.framework/Versions/2.7/bin/python is not MacPorts python; it's some other python you have installed outside of MacPorts. It will have no knowledge of python modules you install with MacPorts. To use MacPorts python modules, you must use MacPorts python, which is /opt/local/bin/python2.7. You can either run it by that absolute path, or if you want to be able to run it by just typing "python", then you can first run sudo port select python python27 and then close and reopen your terminal window.

Thank you! That has got it working. However, the sudo command did not work for me and I instead had to add an alias in my .profile file to use the correct file path to run "python".

comment:3 Changed 8 years ago by mf2k (Frank Schima)

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.