-
-
Notifications
You must be signed in to change notification settings - Fork 391
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
ImportError: No module named 'gi._gi' while runnint setup.py on linux mint #94
Comments
Thanks for the report! It's likely the issue is an incompatibility with Linux Mint - that's not a distro we test extensively. As a check - can you run the project outside of briefcase? That is, can you run |
Thank you for the quick response. Odd results of that experiment. (venv) 06:54:07 jima ~/coding/tut3/helloworld $ python -m helloworld I gave pip install toga a shot and got different results of the experiment afterwards: OK. That's odd. I edited the project's main.py file changing: So, looks like a Mint support problem. I'm surprised. I didn't think Mint strayed too far from Ubuntu, but I'll admit I don't follow that all too closely. I'm happy to dig in more if that's desired. Thanks again for the time and attention, and for helping to make this project! |
Thanks for that detail. As you've surmised, it looks like it's a Mint support problem. If you're interested in some more detailed debugging, the problem code is here. The issue is that GTK requires some system libraries; but you can't install the Python bindings for GTK using If you're outside a virtual environment, you should be able to run What toga_gtk/app.py does is attempt the import; and if it fails, it tries to create the symbolic links (because the source libraries are in a known location on any given operating system) to the virtual environment directory (which is known because we're running in that virtual environment). Taking a closer look at the exact error message you originally reported, it might be possible that there's a dependency missing - the import of gi itself isn't failing, it looks like a missing SO - which suggests theres a binary library missing somewhere. If you can poke around why this |
Alright. I poking around and then, finally, taking your earlier suggestion of running "import gi", I think I have a new theory. This is mint 17.3 which ships with py2.7. I had, a while back, built and installed py3.4. I ran into a problem, I think having to do with the cookiecutter template not having py3.4 branch, and so just built 3.5. It looks like the path work in the app.py file is pulling from /usr/lib/python3. Running /usr/bin/python3 gets me the 3.4 version. Outside of the venv, if I run py3.5, import gi, it fails (no module). If I run 3.4, the import works fine. I'm beginning to suspect that my python installs are not clean. ------ more details below - just in case you're curious and so I don't lose the info ------ The except block here is what raises the "unable to automatically create...." exception. |
Ah - that would make sense. If the "outside venv" run of However, the easier fix may be to resolve the initial problem: the absence of a Linux template for Python 3.4. The Linux template isn't that complex, so I've just pushed a naïve port of the 3.5 template that should allow you to deploy on a system native Python 3.4. Let me know if that works for you. The Linux template is really simple, and needs a lot of work - in particular, I'd like to start using Flatpak so that apps are easily redistributable. If you're at all interested in helping out, that would be a huge help. |
Awesome! |
@freakboy3742 : Tested and confirmed that it now works for Python3.4. Thank you! So, I am interested in helping out. I've looked at the Thanks again! |
@jima80525 Awesome - thanks for testing that! The repository that needs work is this one. https://github.com/pybee/Python-Linux-template This is a utility repository that is used by Briefcase when it rolls out a Linux project. The underlying feature request for Linux support is this one: #2 While a PR against the template repository and briefcase would be amazing, you don't even need to go that far. If you're able to take a simple app (like the tutorial) and provide me step-by-step instructions for turning it into a "flatpak app" - whatever that means - I can turn that documentation into a code patch. That is, assuming I only have the code as described in the tutorial:
As much as possible, follow the conventions that other platforms use - an "app" directory where the application code is contained, and an "app_packages" directory where any requirements are installed. However, beyond that... just document the process. Does that make sense? |
@freakboy3742 - Thanks again for the help eariler. |
@jima80525 No worries at all - Any help you can provide, on whatever timeline you can provide it, is gratefully accepted! |
OK. I'll preface with this with a "I'm in over my head" claim. I've just started That caveat aside, here goes. To you direct questions:
Everything. It looks like all the way down to python itself, but that might be included in the runtime. I've got an example below (shamelessly stolen from a pygame-flatpak integration) that pulls in py3.6 and builds it. Again, I'm not sure if that's needed. Even if it's not, you'll at least need to pull in all of the packages that are pip-installed into the virtualenv. That pygame-flatpak project (https://github.com/takluyver/pygame-flatpak-test) has a nice example in the python3.6 json file for using pip as part of flatpak to pull in dependencies.
Assume I'll create a "linux" directory to keep the flatpak isolated from everything else (e.g, the macOS build, the Windows build, the iOS build,...) - what structure is needed beyond that?
As far as I can tell, you'll need a single json file to configure flatpak. There are details in the flatpak page, below, and at the pygame page.
To build it use
This may get a little tricky, as the user can specify which "repo" it should be Some more general notes: There are at least three one-time steps users will need to take to get flatpak to work on their systems:
NOTE: despite flatpak being pre-installed on mint18.3, I still had to manually install
Once users have done that, they via briefcase, will need to create a json config file. Two issues I see: a) The config file points back to the runtime installed in step 2. If that is different the json needs to change Here's the simplest example from the flatpak demo:
That looks simple enough. The exception is, as listed in point b above, there will This starts to look like this:
Also to note: python itself might need to be packaged. There's a project built around pygame which appears to do this. The python3.6 version of the json file which pulls in python looks like this:
That's what I have for now. I appologize that this is not more of a solution, but, as I said, I'm Hope this helps! |
This appears to be an issue with the toga installer, which has been addressed in the 0.3 branch of Toga. |
I'm trying to walk through the tutorial. Here's the bash history:
2001 mkdir tutorial
2002 cd tutorial/
2003 python3.5 -m venv venv
2004 . venv/bin/activate
2005 pip install briefcase
2006 apt-get install python3-gi gir1.2-webkit2-3.0
2007 sudo apt-get install python3-gi gir1.2-webkit2-3.0
2008 pip install --upgrade pip
2009 cookiecutter https://github.com/pybee/briefcase-template
2010 cd helloworld/
2011 vir helloworld/app.py
2012 python setup.py linux -s
All commands were successful until the final one. setup produced a cascade of errors, the first one being:
Installation complete.
Starting Hello World
Creating symlink (/home/jima/coding/tutorial/helloworld/linux/app_packages/gi & /home/jima/coding/tutorial/helloworld/linux/app_packages/pygtkcompat) to system GTK+ libraries...
Creating symlink (/home/jima/coding/tutorial/helloworld/linux/app_packages/gi & /home/jima/coding/tutorial/helloworld/linux/app_packages/pygtkcompat) to system GTK+ libraries...
Traceback (most recent call last):
File "/home/jima/coding/tutorial/helloworld/linux/app_packages/toga_gtk/app.py", line 7, in
import gi
File "/home/jima/coding/tutorial/helloworld/linux/app_packages/gi/init.py", line 36, in
from ._gi import _gobject
ImportError: No module named 'gi._gi'
It indicates that other exceptions occurred during the handling of that one, but I suspect those are not relevant.
I initially attempted this with Py3.4 which failed. I saw in a different issue that I would likely be better off with 3.5. I built and installed 3.5 and that's what's running in the VM. I also had used mkproject instead of creating the venv manually as shown in the example. I backed that out and started a new project doing it the manual way (as shown above).
Looking at the /helloworld/linux/app_packages/gi/init.py file, there is an import there
from ._gi import _gobject
There is not a _gi directory in the gi dir. There are two files which might be related:
_gi_cairo.cpython-34m-i386-linux-gnu.so
_gi.cpython-34m-i386-linux-gnu.so
I'm suspecting that there's some flotsam left over from either the 3.4 attempt or the mkproject attempt that is causing me problems, but I'm not seeing how those would produce the linux directory (in a new, clean subdir) without the required module.
NOTE: just to be complete. I went back and redid the steps after I manually removed the ~/.cookiecutters/ briefcase-template and Python-Linux-template directories. Same result.
Thanks for any help!
The text was updated successfully, but these errors were encountered: