I'm working with Python 2.7.6, Windows 8.1, in PyCharm 3.1.3.
trying to run something that already worked and get the error:
File "C:\something\sources\ParamsWin.py", line 6, in
import gtk ImportError: No module named gtk
Tried to download GTK through project settings, and got:
ImportError: No module named xml.etree.ElementTree
Tried to import element tree package and got the same error.
I've been googling quite a bit and there seems to be a problem with python and this element.
anyone, ideas?
TIA
You say you tried to download GTK?
I've had problems in the past (and the xml.etree... thing does look familiar) when I just installed GTK on its own. The best way of installing gtk in a Windows platform, in my humble opinion, is to use one of the the all-in-one downloaders from here: http://ftp.acc.umu.se/pub/GNOME/binaries/win32/pygtk/2.24/.
Cheers,
Simon
Related
I'm using Python 3 and working in Pycharm.
I was able to get pywin32 and win32com working on one project, but since I have tried importing them into a new project, they don't seem to be working. At first I was getting No module named 'win32api', but I updated the win32com\__init__.py from import win32api to from win32 import win32api. That seems to have fixed the initial error, but now I'm getting No module named '_win32com'. This seems to be from issues with \pythoncom\__init__.py maybe?
I've tried uninstalling and reinstalling pywin32 and pypiwin32 as well.
Example of code here:
import win32com.client as win32
xlapp = win32.DispatchEx("Excel.Application")
wbe = xlapp.workbooks.open(r"C:\Users\me\example.xlsx")
I decided to try again with a new project and install the packages globally and that has fixed the issue. Still not sure why it wasn't working when installing locally, but using global installs seems to be good solution.
I tried to run a nltk code for drawing parse trees. I got the error that tkinter module is not installed.
These are the error messages I got:
1. UserWarning: nltk.draw package not loaded (please install Tkinter library).
warnings.warn("nltk.draw package not loaded")
2. import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
After some searches I installed the ActiveTcl 8.5.18.0 using this instructions.
But when I try to run my code I still get the sam error. I tried
import Tkinter
but I get the second error message above again.
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 39, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: No module named _tkinter
I also looked at Tkinter documentations and it is mentioned that the correct installation of Tkinter can be verified by running the following command which again gives me another error.
command: python -m tkinter
error: /usr/local/opt/python/bin/python2.7: No module named tkinter
I found this answers on Stackoverflow for my problem but they are either not very clear or not applicable to my case.
How to get tkinter working with Ubuntu's default Python 2.7 install?
Problems: tk-dev is not available for OS X (it is same as ActiveTcl) and I couldn't figure out how to rebuilt my python using make
Tkinter: "Python may not be configured for Tk"
Problems: very vague. I don't know what should I do
please help.
You should install ActivePython rather than ActiveTcl, and use it as your preferred Python.
The problem is your Python install isn't picking up your Tcl install, and the simplest way to solve that is to install a Python version that is configured for Tk, which ActivePython is: http://www.activestate.com/activepython
The issue is that the _tkinter Python module is not installed in your build, which is a required bridge between Python and Tk. You will have to reinstall nltk and any other packages you are using, unfortunately, as the versions you have will be installed for your current Python and not your new one.
I can not import modules from gi.repository.
Specifically not Gtk and GObject.
I experienced this error both on Ubuntu 14.04 LTS and after reinstall
also on Linux Mint 17.
from gi.repository import Gtk, GObject
Results in the 'unresolved reference' warning for the respective
modules. Interestingly enough my Gtk GUI can be compiled and works
perfectly fine. Yet, GObject is entirely out of function.
I tried to work around with altering import statements such as:
from gi.repository.Gtk import*
Even hard coding the import path via:
sys.path.append('/usr/lib/python2.7/dist-packages/gi')
None of these approaches have solved this frustrating error so far.
I have not found any concluding help or basic info on this issue,
neither anywhere on the web nor in Linux forums or here on stackoverflow.
I am not sure whether this problem lies on the Python or the Linux side of things.
Can anybody suggest how to solve this issue?
What additional information do I need to provide eventually.
Thanks!
If on a Debian-based system such as Ubuntu, you probably need to install the gir1.2-gtk-3.0 package and other similarly named packages for other libraries. I don't know what the name of the package would be on Mint, but it's probably something similar.
On Wheezy (Debian 7.8) installing python3-gi fixed the problem for me.
I stumbled upon this issue with some old github python examples and it helped for me to add lines:
import gi
gi.require_version("Gtk", "3.0")
reference:
https://python-gtk-3-tutorial.readthedocs.io/en/latest/introduction.html
I'm trying to compile a Python project (using Python 2.7 on Windows XP) into an EXE using PyInstaller with the default options. When I try to run the EXE, I get the message:
PyInstaller - ImportError: No module named win32api
I added the win32api path to the windows PATH environment variable (I do have Python Win32 Extensions installed) but it's not working. I'm pretty new to this and a little overwhelmed by all the options etc, and I really have no idea where to start (or what information would be useful to solving this problem.) I assume this is some little thing that I'm missing, but I haven't found anyone having precisely this problem online and any help would be greatly appreciated.
Ok, it looks like "import os" in one of my modules was causing this issue. I had no luck getting it to successfully use the win32api module, but since this was only being used to set the program name, I just commented this out and this particular issue is resolved. Thanks Luke for your help!
I'm running Python 2.7, with the latest version of GTK installed.
I'm trying to import gtk with the following line of code:
import gtk
It is throwing the following error:
Traceback (most recent call last): File
"C:\GTKTutorial\tutorial.py", line 3, in
import gtk File
"C:\Python27\lib\site-packages\gtk-2.0\gtk__init__.py", line 40, in
from gtk import _gtk ImportError: DLL load failed: The specified
procedure could not be found.
How do I fix this? import pygtk is working, and I have Glade 3.8.0 installed.
Where did you get the PyGTK installer from? Try using this one: http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.22/pygtk-all-in-one-2.22.6.win32-py2.7.msi
I just spent 3 days debugging this issue on my computer. This problem can have many root causes because importing gtk actually causes a lot of DLLs being loaded. If any of them fails, you get the same error message. For me, the break-through was
http://www.dependencywalker.com/
which I used to profile the command
python -i -c "import gtk"
On my PC, a wrong version of zlib1.dll was in the system32 directory, which prevented the right one in gtk\bin from loading. And it did that even though the first entry in my path pointed to gtk\bin.
I deleted the zlib1.dll from system32 (the application that put it there deserves to die) and the import worked fine. Your problem may be different, but dependency walker probably can give you a hint on what is going wrong.
Windows can have other reasons for loading a DLL other than the one you put in your directory or path. I found the blog
http://www.davidlenihan.com/2007/07/winsxs.html
useful. It describes Microsoft's solution for managing many versions of DLLs, and how to troubleshoot problems with it.