-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
Can't use Eve library with pyotherside #77
Comments
I fixed it by adding my own
before the creation of Eve(). |
I seem to have found what may be the root issue here. If I do multiple addImportPath statements before my importModule in QML it will throw weird errors such as this in the Python script. If I only have one addImportPath it behaves as expected. |
File "/usr/lib/python3.5/os.py", line 112, in \n sys.modules['os.path'] = path\n\nAttributeError: module 'sys' has no attribute 'modules'\n" This is the error I get anytime I do addImportPath twice. My goal is to be able to reference other Python modules from my Python script. |
Alright I'm able to do multiple addImportPath with absolute paths like: but not like |
Do you have a Short, Self Contained, Correct (Compilable), Example (http://sscce.org) for demonstrating the issue? |
@thp I will put together an example as soon as I can. |
Here is an example that shows my root import issues: https://drive.google.com/file/d/0B5CPtCs60_W-U3ZEX2E2T3NpU3c/view?usp=sharing Am I supposed to always have my Python and QML files in the same directory? |
I'm still investigating how the importing works. If I take your example project and change it from qrc_example.py to anything else...say test.py, update the .qrc file and .qml file to reference it...it won't work. It will say it had success importing the module but the 'Hello from module!' won't print nor can I call any specific functions. Is it a requirement every python file you call from a qml file has the exact same name? |
No, there is no such requirement, but you might need to tweak the Python import path. |
So I finally remembered this issue and I've noticed it with other libraries too and it boils down to the embedded Python doesn't get the sys.argv attribute set by default. Before importing the offending libraries, which for me have been Eve or systemd-python, you can simply set: sys.argv = [''] and it will cause things to work. I wonder if for wider Python library use in Pyotherside if we should call PySys_SetArgv with an empty array right after you call Py_InitializeEx(0)? This would be preferable to currently where it will just break when importing a certain library. I have tested this in the Pyotherside library and it works:
|
I'm trying to setup an HTTP API in a QML project and when I run the simple quick start python code of:
it works using just Python but when I invoke this .py file with Pyotherside I get the following message:
The text was updated successfully, but these errors were encountered: