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

Add a file with functions instead of importing a package. #251

Closed
silgon opened this issue Mar 30, 2016 · 3 comments
Closed

Add a file with functions instead of importing a package. #251

silgon opened this issue Mar 30, 2016 · 3 comments

Comments

@silgon
Copy link

silgon commented Mar 30, 2016

I would like to call a python function only. For this reason I want to add a python file to my julia package containing this function.
I cannot translate this function to julia because it's generating some errors because some components used in cvxpy (the package I'm using), nonetheless it works fine when I use it alone in python. Thus, I want to avoid creating a whole package only for one function, but I need a python script nonetheless.
Any ideas or thoughts?

@silgon silgon changed the title Add a file with functions instead of a package. Add a file with functions instead of importing a package. Mar 30, 2016
@cstjean
Copy link
Collaborator

cstjean commented Apr 1, 2016

@pyimport can import any Python module including the one you wrote, no need to register a Python package for it, just check out #48. Is that what you're asking about?

@silgon
Copy link
Author

silgon commented Apr 2, 2016

I wanted to import a python script created inside the julia project, because I only had a function depending on some python packages. I don't need it anymore because I did another workaround, but it would be maybe interesting to now the answer =)

@stevengj
Copy link
Member

stevengj commented Apr 6, 2016

You should just be able to do pybuiltin("execfile")("myfile.py"). As I understand it, execfile is the Python equivalent of Julia's include, which seems to be what you want.

(For importing a local module, you just need to set the path appropriately, as @cstjean mentioned.)

@stevengj stevengj closed this as completed Apr 6, 2016
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

3 participants