Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python - Run numpy without the python interpreter

Tags:

python

numpy

I have an .x3d code which references a python script. I am trying to implement certain functions which make use of the numpy module. However, I am only able to import the builtin modules from Python.

I am looking for a way to import the numpy module into the script without having to call the interpreter (i.e. "test.py", instead of "python test.py").

Currently I get "ImportError: No module named numpy".

My question is: Is there a way to import the numpy module without having to call from the interpreter? Is there a way to include numpy as one of the built-in modules of Python?

like image 211
jaykex Avatar asked May 22 '26 19:05

jaykex


2 Answers

  1. find where numpy is installed on your system. For me, it's here: /usr/lib/pymodules/python2.7

  2. import it explicitly before importing numpy

import sys

sys.path.append('/usr/lib/pymodules/python2.7')

... if you need help finding the correct path, check the contents of sys.path while using your python interpreter

import sys

print sys.path

like image 155
laher Avatar answered May 24 '26 09:05

laher


I'm going to guess that your #! line is pointing to a different python interpreter then the one you use normally. Make sure they point to the same one.

like image 36
Winston Ewert Avatar answered May 24 '26 07:05

Winston Ewert