Open VeritasYin opened 7 years ago
Hi,
Looks like a path problem.
First of all - what Matlab version do you have, and can you import other (not VIN) python packages?
Second - can you try following the advice on this page: https://www.mathworks.com/help/matlab/matlab_external/undefined-variable-py-or-function-py-command.html#buiebj2-71 to fix the python path error (seems like you need to add the path to theano)?
Let me know if this works.
Best, Aviv
On Mon, Jan 30, 2017 at 4:57 AM, VeritasPotter notifications@github.com wrote:
Hi! Recently, we tried to reproduce the experiment, but at the visualization part (script_viz_policy.m) has to use MATLAB call python code (vin.py). In this part, the code imports theano module (which I have already installed). But it reported an err: Undefined variable "py" or class "py.vin.vin".
Error in script_viz_policy (line 3) tmp = py.vin.vin; clear tmp; % to load Python
And I followed instruction of Matlab Online Help, used command py.importlib.import_module('vin') for test, and still reported an err:
Error using theano_utils> (line 3) Python Error: ImportError: No module named theano
Error in vin> (line 3) from theano_utils import *
Error in init>import_module (line 37) import(name)
But I can import theano in python,
import theano import theano.tensor as T theano.test() Theano version 0.8.2 theano is installed in //anaconda/lib/python2.7/site-packages/theano NumPy version 1.11.1 NumPy relaxed strides checking option: False NumPy is installed in //anaconda/lib/python2.7/site-packages/numpy Python version 2.7.12 |Anaconda 4.2.0 (x86_64)| (default, Jul 2 2016, 17:43:17) [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)] nose version 1.3.7
I couldn't figure out where is the problem. Thank you in advance!
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/avivt/VIN/issues/9, or mute the thread https://github.com/notifications/unsubscribe-auth/AOeQNcB4WvE3kGRLCjnqeMRkedLks5SJks5rXd4mgaJpZM4LxXww .
Hi, Aviv!
It still doesn't work on Matlab R2016b.
I followed the instruction of Matlab documents, added the path into python.
P = py.sys.path; P
P =
Python list with no properties.
['/Users/veritas/Desktop/vin', '/anaconda/lib/python2.7/site-packages/theano', '', '/usr/lib/python27.zip', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-darwin', '/usr/lib/python2.7/plat-mac', '/usr/lib/python2.7/plat-mac/lib-scriptpackages', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/Library/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC']
I can import my own python file like mymod.py and module like numpy with no problems,
py.importlib.import_module('mymod')
ans =
Python module with properties:
theend: [1×1 py.function]
search: [1×1 py.function]
<module 'mymod' from 'mymod.pyc'>
py.importlib.import_module('numpy')
ans =
Python module with properties:
loadtxt: [1×1 py.function]
reciprocal: [1×1 py.numpy.ufunc]
......
But if I want to import theano or vin.py, it reported errors:
py.importlib.import_module('theano') Error using init>import_module (line 37) Python Error: ImportError: No module named theano
py.importlib.import_module('vin') Error using theano_utils>
(line 3) Python Error: ImportError: No module named theano Error in vin>
(line 3) from theano_utils import * Error in init>import_module (line 37) import(name)
And also, the path for theano is a dictionary, maybe this method only works for a file (Matlab tries to find a file named theano.py?) rather a dictionary. But still, numpy is also a dic, so I am confused.
Many thanks, veritas
I am having a similar problem. is your problem solved?
Hi! Recently, we tried to reproduce the experiment, but at the visualization part (script_viz_policy.m) has to use MATLAB call python code (vin.py). In this part, the code imports theano module (which I have already installed). But it reported an err: Undefined variable "py" or class "py.vin.vin".
Error in script_viz_policy (line 3) tmp = py.vin.vin; clear tmp; % to load Python
And I followed instruction of Matlab Online Help, used command py.importlib.import_module('vin') for test, and still reported an err:
Error using theano_utils> (line 3)
Python Error: ImportError: No module named theano
Error in vin> (line 3)
from theano_utils import *
Error in init>import_module (line 37) import(name)
But I can import theano in python,
I couldn't figure out where is the problem. Thank you in advance!