Thanks Steven,
That's a neat trick - I'll keep that in mind. However, this would require
me to load PyCall in .juliarc.jl, which I in general do not want to do.
Adding "mypath" to PYTHONPATH by ENV["PYTHONPATH"] =
join([ENV["PYTHONPATH"],mypath]) in .juliarc.jl makes @pyimport look in
"mypath" for .py files. This is handy bacause I'm not required to load
PyCall at startup.
Cheers,
Oliver
Den fredag den 9. maj 2014 00.56.53 UTC+2 skrev Steven G. Johnson:
>
> require("file.py") will try to load file.py as a Julia file, which is not
> what you want.
>
> You don't add files to paths, you add directories. For example, this will
> add a directory "/foo/bar" to the Python search path:
>
> unshift!(PyVector(pyimport("sys")["path"]), "/foo/bar")
>
>
> search path. You can then do @pyimport baz to import a Python module
> /foo/bar/baz.py.
>
> On Thursday, May 8, 2014 8:06:49 AM UTC-4, Oliver Lylloff wrote:
>>
>> Hello all,
>>
>> I have a basic .juliarc.jl script that adds various utility functions to
>> LOAD_PATH - as described in previous posts:
>> addpath<https://groups.google.com/forum/#!searchin/julia-users/addpath/julia-users/-zGh3imIUb4/BOyPsp190QEJ>
>> and search
>> path<https://groups.google.com/forum/#!searchin/julia-users/search$20path/julia-users/mxzztIZn-1Q/8lPKdwzXGI4J>
>> This works fine with .jl files but now I want to add a python function to
>> LOAD_PATH such that @pyimport from PyCall can find it.
>>
>> I get an "ERROR: syntax: invalid character literal" due to a triple quote
>> (''') multiline comment in the python function. This error makes good sense.
>>
>> Any ideas on how I can do a 'require("file.py")' to make file.py part of
>> the julia search path?
>>
>> Best,
>> Oliver
>>
>>