I have an application which depends on PyGTK, PyGobject, and PyCairo that I built to work on Linux. I want to port it over to windows, but when I execute import gobject I get this:
Traceback (most recent call last):
import gobject
File "C:\Python26\lib\site-packages\gtk-2.0\gobject\__init__.py", line 30, in <module>
from gobject.constants import *
File "C:\Python26\lib\site-packages\gtk-2.0\gobject\constants.py", line 22, in <module>
from _gobject import type_from_name
ImportError: DLL load failed: The specified procedure could not be found.
This appears to be caused by the switch from building using MinGW to Microsoft Visual Studio, as documented Python Bug 3308 (closed: wontfix).
Is there any way to install PyGTK/PyGObject in a way that will work with Python 2.6 on Windows, without having to recompile one or the other from source?
I have it working fine, and it didn't give me much trouble, so we know it can be done...
Keep in mind you will probably need all of the following installed on your Windows machine:
PyCairo ( http://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/ )
PyGobject ( http://ftp.gnome.org/pub/GNOME/binaries/win32/pygobject/ )
PyGTK ( http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/ )
Unofficial x64 versions of the above 3 items are available here -- However, I cannot vouch for nor recommend them!
and of course
the GTK+ Runtime ( http://ftp.gnome.org/pub/GNOME/binaries/win32/gtk+/ or http://ftp.gnome.org/pub/GNOME/binaries/win64/gtk+/ )
I suspect in your case that the PyGTK libraries are not finding your GTK+ Runtime directory where the DLLs are. You should have the environment variable GTK_BASEPATH set to the directory of your GTK+ Runtime (usually C:\GTK).
Please also see the PyGTK-on-Windows FAQ
Now, if you're trying to compile the PyGTK'ed Python with Py2EXE, that's a bit more complicated, but it can be done as well...
The PyGTK all-in-one installer has been updated recently:
http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.22/
This will install PyGTK, PyGObject, PyCairo, PyGtkSourceView2, PyGooCanvas, PyRsvg, the gtk+-bundle and Glade. It is absolutely everything necessary to be able to successfully import gobject, import gtk, etc, without DLL problems.
for 64 bit Windows users see
http://digitalpbk.blogspot.in/2012/03/installing-pygtk-pypango-and-pycairo-on.html
Above steps will give Invalid DLL error on 64 bit.
u should have pygtk,pycairo,pygboject and the gtk+ runtime...
see this for an all in one installer
http://aruiz.typepad.com/siliconisland/2006/12/allinone_win32_.html
Be careful about installing PyGTK bundle pack if any one planning to run PyGTK through embedded interpreter and the C/C++ code is already using GTK. PyGTK bundle pack does not add its GTK runtime to PATH.
In such case possibly the C code will take GTK from PATH (as probably you have already installed GTK bundle pack) and Python will use separate set of GTK runtime libraries.
Therefore in my case either C GUI or Python GUI used to run properly and used to conflict while running together.
As I use Psychopy as my base python collection, to solve this problem I have just installed PyGTK PyGTK, Pycairo, Pygobject on top of Psychopy.
Apart from using only one set of GTK runtime I had to initialize GTK in my C code through PyGTK (not by gtk_init (&argc, &argv) in my C code) after initializing python interpreter.
Related
I am using windows 7 and Autodesk Maya 2014.When i am trying to import Tkinter i am getting error.please tell me how to solve error given below ?
How to install any python package in Auto desk Maya 2014 ?
import Tkinter
Error
Error: line 1: ImportError: file C:\Program Files\Autodesk\Maya2014\Python\lib\lib-tk\FixTk.py line 65: DLL load failed: %1 is not a valid Win32 application
I added a few Python modules to Maya with the "addsitedir-trick" explained at the end but not every python module will be playing nicely with Maya.
Python on Windows is built with Visual Studio 2008 Professional. Maya uses it's own Python interpreter but Autodesk builts Maya with another Visual Studio version. This can lead to problems if you insall python modules and try to use them with Maya. Beatuifully explained here (together with a the hard solution of compiling the wanted modules yourself):
http://p-nand-q.com/python/building-python-27-with-vs2010.html
What you can try: Install Python 2.7 on your Windows-box, install the module you want to access in Maya (eg with pip). Now in Maya add your system SitePackages (where you just installed the module to) to your Maya-Python-Interpreter SitePackages like so:
import site
site.addsitedir("/path/to/your/python27/Lib/site-packages")
Even cleaner solution would be to use a virtualenv instead of the global site-packages folder! (That's at least what i have done to get psycopg2 and requests play with Maya)
But as mentioned in the beginning of this answer there is a possibility that this may fail (with strange errors).
By the way: I highly recommend to use pyside instead of Tkinter if you want to do GUI stuff in Maya. Or the Maya-Wrappers preferably via pymel. (http://help.autodesk.com/cloudhelp/2017/ENU/Maya-Tech-Docs/PyMel/ui.html)
I'm using CXFreeze with PySide (QT). I get an error:
cx_Freeze: Python error in main script.
myscript.py line 33, in
File ExtensionLoader_Pyside_QtGUI.py, line 11, in
Import Error: DLL load failed: The specified module could not be found
When running a fresh install of Windows server 2008.
I'm running the frozen EXE package (with the folder). It seems to work on my own system and other systems. What might be the issue?
After reading, online, I tried to replace the Qt4Gui file, but this didn't solve the issue.
Python version is 2.7
Based on your Import Error: DLL load failed it is most likely an installation issue causing the missing DLL. To figure our exactly which DLL you are missing, use http://www.dependencywalker.com/ Run the .exe and open the .pyd file for File ExtensionLoader_Pyside_QtGUI.py and it will show you exactly which DLL's are missing and more importantly the locations where they should be. You can probably then track down the missing DLL online.
there are known issues with pyside 1.2.0 and cxFreeze. All should be fixed in development version (available on git repo). Please build the PySide from latest sources yourself or wait for PySide version 1.2.1. Build instructions are here [1].
[1] https://github.com/PySide/pyside-setup#building-pyside-on-a-windows-system
I used Py2exe instead of CXFreeze and it worked perfectly.
Also, apparently Python requires the MS Visual C++ Dependency Files:
http://www.microsoft.com/en-us/download/details.aspx?id=29
So any bundling needs that as well, if it's a fresh install. (Although I think they are now bundled with newer Windows versions.)
Other Notes:
In my experience, sometimes you should try CXFreeze, Py2EXE and PyInstaller quickly and see if one works best. As ideal as CXFreeze is re: cross platform, it just isn't going to happen perfectly.
Also, while I don't know if this was a factor, I set up a Windows 2000 Pro virtual machine and ran Py2exe on that. That was to ensure compatibility for all older Windows versions, and seemed to work well. (NOTE: Many things won't even run on Win2000 anymore so be careful that your other tools and libraries will run on it.)
Finally, be extra careful to match the bit level (32 vs 64) of all your libraries, and your Python install itself. If you have 32-bit python, ensure that your PySide, CXFreeze and any other libraries you use are 32-bit. (Or 64-bit if you're using 64-bit python.)
I just fixed a bug in a two year old python program and now I'm having big trouble getting it to compile again. I simply cannot get Python, Cairo, wx and distutils to work together.
On OSX I managed to get Python 2.7 to import Cairo and WX but py2app does not work. The error is something about unknown architecture.
On Windows 7 I have not been able to successfully import cairo. I installed py2cairo and put the libcairo-2.dll in Windows/System32 but still get an import error. I even copied msvcr90.dll to System32 but still no luck.
Does anyone have a combination of Python, wx, Py2cairo, Cairo and distutils that just works? I need Python 2.6 or 2.7 32 bit on OSX and Windows.
I got it to work on OSX by installing an older version of XCode form the SnowLeopard DVD.
You also have to be very careful with paths to data files because py2app puts everything into a zip file.
py2exe was worse because it did not copy dynamically loaded modules and one dependency from pytz into the repo and needed some ugly hacks in setup.py.
I ended up using cairo-1.10.2, libpng-1.2.49 and pixman-0.20.2
I installed TkTreeCtrl 2.4.1 (written in c), as well as TkTreectrl 1.0 ( written in python), which wraps the original c library.
When I try to create any treectrl objects in Python, I get the error:
_tkinter.TclError: can't find package treectrl
I'm pretty new to Python, but I'd guess that the Python wrapper code can't find the c library.
When I installed TkTreeCtrl(c) it installed itself in '/usr/lib/treectrl2.4.1' as a .dylib file.
I've never used a .dylib before, but some googling told me to add the directory it was in to the environment variable 'DYLD_LIBRARY_PATH'.
I did that, but no luck. I'm not sure I'm even know what my problem is, so any help would be greatly appreciated!
I'm running Lion and Python 2.7. Python was installed using MacPorts.
For its Python ports, MacPorts currently builds and installs its own X11-based Tcl and Tk ports. It looks like you would need to be careful when building TkTreeCtrl to specify the correct locations to ./configure for the MacPorts provided Tcl, Tk, and X11 libraries and include files. See ./configure --help for the names of the options. You should find the libraries and include files under /opt/local/, the default install location for MacPorts files.
There may be an easier option, though. It appears that the ActiveTcl distributions for Tcl/Tk include TkTreeCtrl. If you use a Python that links with ActiveTcl, you would just need to install the Python TkTreectrl module, which is straightforward. On Lion, a free (though not open source) download of ActiveTcl 8.5 is available here which will automatically be used with the python.org 2.7.2 64-bit installer for OS X available here. ActiveState also has its own Python distribution for OS X. There's more information about some of the quirks of Python and Tcl/Tk on OS X here. Note that the ActiveTcl is a more native implementation on OS X; it is not X11-based.
I've been trying to install PyQt 4.7 on Vista, but I am getting an ImportError when I try to do: from PyQt4 import QtCore, QtGui.
ImportError: DLL load failed: The specified module could not be found.
I've checked my System Path, and C:\Python31\Lib\site-packages\PyQt4\bin is on there.
I can't run any of the examples, but the Designer, Assistant and Linguist run fine.
I am using ActivePython 3.1, if that makes any difference. And I haven't had any previous version of PyQt installed.
Edit:
I've copied the QtCore4 and GtGui4 dlls to C:\Python31\Lib\site-packages\PyQt4. That fixes some of the examples, but I still can't use the example browser.
Are you sure there is a \bin directory for your version of PyQt?
I am running PyQt 4.4, and all my binaries are right in:
C:\Python31\Lib\site-packages\PyQt4
Which is what I have my path pointing too.
It sounds like PyQt4 was installed improperly... did you run this?
python setup.py install
There shouldn't be a bin there...
Just wanted to chime in that I had the same problem on a WinXP install of:
python 2.7
Qt 4.7.1 (10.05)
PyQt 4.8.1
I used the windows installer version of all 3 of those items.
Copying the contents of the C:\Python27\Lib\site-packages\PyQt4\bin folder up to the main PyQt folder (C:\Python27\Lib\site-packages\PyQt4) stopped the 'dll not found' errors that python was throwing.
Also chiming in. I installed both python 2.6 and PyQt 4.8.3 on a Windows 7 machine using the windows installers (I did NOT run 'python setup.py install').
I tried to run spyder (which requires PyQt 4.4 or greater) and failed because it couldn't find the PyQt .dlls. I copied all the .dlls from the \Lib\site-packages\PyQt4\bin folder to the \Lib\site-packages\PyQt4 folder, and spyder launches just fine.
PyQt installation also depends on the version of python installed on your platform.Python3.+ is incompatible with Python version < 3.x.
I was facing the same problem as I have Python 2.7 installed on my machine but I downloaded the latest binary which was PyQt-Py3.2-x86-gpl-4.9.exe. If you see here the binary has python version also mentioned in name after PyQt which is Py3.2. I uninstalled PyQt and installed PyQt-Py2.7-x86-gpl-4.9.exe which points to Python 2.7 and it fixed the problem.
Probably they could have mentioned the naming convention online or in some documentation to be more simpler.
I had the same problem. I got my program running from within Eclipse but when I tried running it directly from the command line I still got the same error.
I solved it by renaming the C:\Users\Me\AppData\Roaming\Python\Python27\site-packages\PyQt4 directory. (I'm guessing leftovers from a previous PyQt install)
I am using ActivePython.
I think there are at least two possible error conditions
1. ImportError: DLL load failed: The specified module could not be found.
then you have to check your PyQT version is comptible with your python. In other words, if you use python 3.3, then you can only use PyQT for python3.3 and python 3.3 will not work with PyQT for python3.4
This was the problem I met. I solved it with re-install it
2. Import Error: DLL load failed: %1 then something strange on a different encoding Win32.
then it would be a OS problem. If you use 32bit Python then you have to use 32bit PyQt, so do 64bit
Here's how I could fix those errors on Windows 7:
Get the PyQt4 wheel from
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4.
Make sure that the version is exactly the same as your Python version (i.e. Python 3.3 doesn't work with PyQT for Python 3.4). Also make sure to download the 64bit version if you are on a 64bit machine and vice versa.
Extract the wheel with 7zip
Rename the PyQt4-4.11.4.data (or similar) directory to PyQt4
Go to PyQt4\purelib\PyQt4\ and move everything to the root PyQt4 folder. You can delete the purelib folder now
Copy the whole PyQt4 folder to your Python interpreters 'site-packages' folder (e.g. C:\Python34\Lib\site-packages)
Go to PyQt4\data\Lib\site-packages and move all the files to C:\Python34\Lib\site-packages\
In my case I needed MSVCP140.dll. I have solved this problem by dowloading Visual C++ Redistributable for Visual Studio 2015:
https://www.microsoft.com/en-us/download/details.aspx?id=48145
Got this solution from MSVCP140.dll missing
I am using Pyqt4 and Python 3.6 in Windows7.