Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing python files #501

Closed
ayush1999 opened this issue May 11, 2018 · 1 comment
Closed

Importing python files #501

ayush1999 opened this issue May 11, 2018 · 1 comment

Comments

@ayush1999
Copy link

ayush1999 commented May 11, 2018

Suppose I have a main.py file and I want to call the functions inside this file from Julia. So, if the file is in the same directory, doing @pyimport main gives me an error:

julia> @pyimport hello
ERROR: PyError (ccall(@pysym(:PyImport_ImportModule), PyPtr, (Cstring,), name)) <class 'ModuleNotFoundError'>
ModuleNotFoundError("No module named 'main'",)

Stacktrace:
[1] pyerr_check at /home/ayush99/.julia/v0.6/PyCall/src/exception.jl:56 [inlined]
[2] pyerr_check at /home/ayush99/.julia/v0.6/PyCall/src/exception.jl:61 [inlined]
[3] macro expansion at /home/ayush99/.julia/v0.6/PyCall/src/exception.jl:81 [inlined]
[4] pyimport(::String) at /home/ayush99/.julia/v0.6/PyCall/src/PyCall.jl:374

I tried other options too, but to no avail. How can I import this specific file?

@stevengj
Copy link
Member

Duplicate of #48. You just need to add the current directory to sys.path, as explained in that issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants