I am currently trying to use GTK3 and Python3 for GUI development.
Everything is working fine while doing this on my Ubuntu device, but as I want to be able to have Windows executables later, I need to set these tools up on Windows 7.
I have Python 3.4.4 (64 Bit) installed on my system and tried solutions from other posts on Stackoverflow to be able to use GTK with it, but I was not able to get it to work.
When trying to import Gtk (import gi and from gi.repository import Gtk) on the Python shell, the following error occurs:
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 2158, in _find_spec
AttributeError: 'DynamicImporter' object has no attribute 'find_spec'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python34\lib\site-packages\gi\importer.py", line 100, in find_module
'introspection typelib not found' % namespace)
ImportError: cannot import name Gtk, introspection typelib not found
What I have installed at the moment:
PyGi 3.18.2 AIO for Python 3.4 64-bit
GTK3-Runtime Win64 (bin directory created during installation is included into PATH)
Which is the best way to get a working set of Python3 and GTK3 on Windows? (As far as I have seen it is not possible to create Windows executables using Ubuntu.)
You need only to install Python 3.4 and the PyGObject project on sourceforge (the one you mentioned in your post).
This setup must work on Windows, because it works for me.
Maybe you missed to check the Gtk3 libraries during installation of PyGObject (this is a frequent error).
You don't need msys2 at all to use PyGObject in Python.
Related
I installed python 3.8.8 and installed wxpython using pip at terminal
pip install wxpython
and i run simple program
import wx
print(wx.version())
in pycharm and pycharm`s python console, I got
ModuleNotFoundError: No module named 'wx'
in IDLE, I got
Traceback (most recent call last):
File "C:/Users/tasoo/OneDrive/Desktop/wx.py", line 1, in <module>
import wx
File "C:/Users/tasoo/OneDrive/Desktop\wx.py", line 2, in <module>
print(wx.version())
AttributeError: partially initialized module 'wx' has no attribute 'version' (most likely due to a circular import)
in python.exe code works
I want to import wx in pycharm project.
I tried add python in system path but it didn`t work.
You have problem because you saved code in file wx.py and now import wx loads your file wx.py instead of module wx. Rename your file - ie. main.py instead of wx.py
PyCharm may have own Python installed and it may need to install wx in this Python.
Check
import sys
print(sys.executable)
to get full path to Python used by PyCharm and then use this path
/full/path/to/python -m pip install wx
Or search in PyCharm settings (in menu File) and change Python Interpreter.
In PyCharm for every project you may set different Python - if you have installed many versions.
I have installed Python 3.4 and wxPython Phoenix on Windows 10. I go into Eclipse and add wxPython to the external libs in my project, but when I try to import it, I get this error:
Traceback (most recent call last):
File "C:\Users\linus\workspace\MiCS 1.2\main.py", line 1, in <module>
import wx
File "C:\Python34\Lib\site-packages\wx\__init__.py", line 17, in <module>
from wx.core import *
File "C:\Python34\Lib\site-packages\wx\core.py", line 6, in <module>
from ._core import *
ImportError: DLL load failed: The specified module could not be found.
I did some searching and tinkering and still can't figure out what's causing it. It shouldn't be the msvcp or msvcr DLLs as I have Office running just fine (or is that an incorrect assumption?) Any help is appreciated. Thanks.
How did you install wxpython?
As of now, the top page of the official site has wxpython 3.0 only for python27. So, I suspect you might not have installed it properly.
If you have your python34 at C:/Python34 then, cd to C:/Python34/Scripts first so that we make sure to use the pip for this python.
According to this post (https://groups.google.com/forum/#!topic/wxpython-dev/LmGIrQyh7jc), try
pip install -U --pre -f http://wxpython.org/Phoenix/snapshot-builds/ wxPython_Phoenix
This should find the corresponding whl file for your python version and CPU architecture.
Or, you could manually download whl file at http://wxpython.org/Phoenix/snapshot-builds/
If you have 32 bit Python34, then look for ******-cp34-none-win32.whl
and simply do:
pip install path/to/the/whl/that/you/just/downloaded/wxPython_Phoenix-3.0.3.dev1839+4ecd949-cp34-none-win32.whl
After this, if you can import wx in the normal cmd then the problem should be coming from eclipse.
I am trying to use the pyside tool on Windows to make a python file out of a .ui
I've installed pyside version 1.2.1-6 from the canopy distribution.
C:\Users\nick\Desktop\pump_project>pyside-uic.exe history_dialog.ui -o kalimera.py
Traceback (most recent call last):
File "c:\users\nick\appdata\local\enthought\canopy\user\scripts\pyside-uic-scr
ipt.py", line 8, in <module>
from PySide.scripts.uic import main
ImportError: No module named scripts.uic
Perhaps an error in your .ui?
pyside-uic apparently works fine for me, at least doesn't fail (using Canopy 1.4.1) compiling this example .ui -- https://qt.gitorious.org/pyside/pyside-examples/source/d4e4c7fdf71ab52083e49ffdea1b7daeff6c8d8d:examples/pyuic/demo.ui
I've been tearing my hair out and trying the solutions to getting Python and MySQL to play nicely with 64-bit architecture, and the solution seems to have all components installed/run as 32-bit.
My issue is that for some reason, running Python in 32-bit mode via
$ arch -i386 /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
and then
import MySQLdb
gives me
import MySQLdb
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named MySQLdb
However, when I run python in 64-bit mode and trying 'import MySQLdb' I get the dreaded:
import MySQLdb
Traceback (most recent call last):
File "", line 1, in
File "build/bdist.macosx-10.6-intel/egg/MySQLdb/init.py", line 19, in
File "build/bdist.macosx-10.6-intel/egg/_mysql.py", line 7, in
File "build/bdist.macosx-10.6-intel/egg/_mysql.py", line 6, in bootstrap
ImportError: dlopen(/Users/me/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so, 2): no suitable image found. Did find:
/Users/me/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.6-intel.egg-tmp/_mysql.so: mach-o, but wrong architecture
So my question is, why can't Python find the module in 32-bit mode? the "wrong architecture" error leads me to believe that MySQL-python is installed as 32-bit, so I don't think it's that 32-bit Python can't "see" the module. I have both the python and the .python-eggs path on my $PATH in .bash_profile, so what am I missing here?
Not exactly an answer, but have you tried just to pip install MySQL-python? If you have some mysql_config in your path, it should compile just fine.
– I am using a Python 2.7.2 via homebrew, a MAMP 2.0 installation, running on 10.6. with a 64bit kernel.
I am trying to run my GTK app on Windows XP and I am having troubles with an import. I have installed the following as needed and recommended:
python-2.6.msi
gtk2-runtime.2-16.6.exe
pycairo-1.8.6.exe
pygobject-2.20.0
pygtk-2.16.0.exe
pyserial-2.5.exe
However, I am getting the following error when running my script:
Traceback (most recent call last):
File "C:\python26\app\src\start.py", line 22, in <module>
import gtk
File "C:\Python26\Lib\site-packages\gtk-2.0\gtk\__init__.py", line 30, in <mod
ule>
import gobject as _gobject
File "C:\Python26\Lib\site-packages\gtk-2.0\gobject\__init__.py", line 26, in
<module>
from glib import spawn_async, idle_add, timeout_add, timeout_add_seconds, \
File "C:\Python26\Lib\site-packages\gtk-2.0\glib\__init__.py", line 22, in <mo
dule>
from glib._glib import *
ImportError: DLL load failed: The specified module could not be found.
GTK is installed into C:\gtk\bin and is setup in my System PATH.
Am I missing something obvious here?
Any help would be appreciated.
Thank-you kindly.
Andy
I was getting the same issue - I'm not sure why, but I suspect it has something to do with some of the install/lookup paths. I tried adding all sorts of stuff to my path, but nothing seemed to work.
What I did to fix it was to uninstall python et. al. and reinstall using the Python (x,y) package. It's a fairly large download, but it has tons of tools, including several (matplotlib, numpy, scipy, IPython, etc) that I needed/wanted.
You could install pygtk bundle found in this page:
http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.22/
where you should find the "all in one" installer suited to your version.
It solved the problem to me without having to install Py(x,y), which seems to be a very usefull scientific environment for windows (I use linux and install all these packages from script).