I have tried the solution suggested on #48 , but it is not working. I am using Julia 0.6.2 on Windows with Python 2.7 and the program is
using PyCall
unshift!(PyVector(pyimport("sys")["path"]),"")
@pyimport Leitura_Sistema_REDS as ls
and I get the error message
ERROR: LoadError: PyError (ccall(@pysym(:PyImport_ImportModule), PyPtr, (Cstring,), name)
The Python package Leitura_Sistema_REDS could not be found by pyimport. Usually this means
that you did not install Leitura_Sistema_REDS in the Python version being used by PyCall.
Activity
YP-Ye commentedon Oct 24, 2018
I get the same error. unshift!(PyVector(pyimport("sys")["path"]),"") does not work.
stevengj commentedon Oct 25, 2018
What is your current directory? i.e. what is
pwd()? Are you sure that you are in the directory with the module that you want?YP-Ye commentedon Oct 25, 2018
Sorry, I found that my problem is caused by a python module named gurobipy. The problem is solved after reinstalling the module.
tkf commentedon Oct 26, 2018
Adding an empty string to
sys.pathis not really a good practice. I think the right approach ispushfirst!(PyVector(pyimport("sys")["path"]), @__DIR__). This way, running Julia script works in any directory. This is close to what Python interpreter does when executing a script (it does not add""tosys.path). Here is an example:Of course,
pyimporthas to be done in__init__if you are creating a Julia module.(We probably should add this to README)
MaxandreJ commentedon Nov 6, 2018
In the README I think instead of suggesting the command
pushfirst!(PyVector(pyimport("sys")["path"]), "")I would have writtenpushfirst!(PyVector(pyimport("sys")["path"]), "<path_to_be_added>")or something like this. I found myself replacing"path"by the path I wanted to add... I'm sure other people will make the same mistake.