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
>
>