maya2008 win32api 64 bit python - python

How is it possible to run import win32api successfully on a 64bit maya version 2008?
The following error occurs:
Error: No module named win32api
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named win32api
I need to get mouse cursor position in python so that I can place window exactly in that position. Is there any other way to get it?
Best regards,
kNish

Maya uses its own Python installation. You need to add the path where pywin32 is installed by one way or another ... you can create a .pth file in
C:\Program
Files\Autodesk\Maya2009\Python\Lib\site-packages\
Also, like Adam pointed out, make sure you have the 64 bit pywin32 installed.
Here's an article talking about this subject:
http://www.rtrowbridge.com/blog/2008/11/27/maya-python-import-scripts/
Edit:
Yeah indeed I think they don't provide PyWin32 for Python25 x64:
Available for AMD64 versions of
Windows for Python 2.6 and later
(support for Python 2.5 is just too
hard, sorry). Lots of help from
Roger, Steve Yin and Sidnei da
Silva.
http://sourceforge.net/project/shownotes.php?release_id=603349

Related

Error importing Zelle's graphics.py package

I am working though Zelle's Python book (Python 2.7.5, Canopy Express, Windows 7). For Chapter 5 you need to install his graphics package, graphics.py. I downloaded the current version, put it in the C:\Python27\Lib\site-packages folder and made sure the file has the '.py' extension, but when I type >>import graphics I get the following error in both Canopy and IDLE:
ImportError
Traceback (most recent call last)
<ipython-input-1-e6fd1288a7fc> in <module> ()
----> 1 import graphics
ImportError: No module named graphics
To the best of my knowledge I've followed the instructions and hints on the website and here in StackOverflow, but I'm flummoxed. Any suggestions? I like the Zelle book but I'm not sure how much use it will be from this point on without the graphics package - from just skimming it seems like the majority of the examples and exercises use it. Thanks.
It took a while, but I got it working. Enthought Canopy uses its own (virtual) environments, so you need to put Zelle's graphics package there, not in the system library. I had success by placing graphics in Enthought's top level directory, which you can determine in the interpreter:
>> import site
>> site.getpackages()[0]
I copied the graphics package there, without the .py extension, fired up Canopy and I was off and running. Thanks to everyone who has posted, in various places, tips on importing - eventually it made sense! By the way,
>> site.getpackages()
will give you all site package directories, but I only needed the first.

ImportError: DLL load failed: not a valid Win32 application

I am trying to use Cython to wrap a C++ class. Basically I follow the example at this page.
I'm using Windows7 64-bit, Python 2.7.4 64-bit, MinGW 4.3.3 (32/64bit), and the SDK has been set to x64 mode.
In this case, I successfully build the .pyd file. I tried to import it with following code:
import sys
sys.path.append("C:\\Rectangle")
import rect
The first two lines work well. When I input the third line, it gave following message:
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import rect
ImportError: DLL load failed: %1 is not a valid Win32 application.
I compiled the extension in 64bit mode, and every piece of software I used is at least compatible with 64bit. How could such error happened?
May I know how can I work around this?
Many thanks! :-)
I ended up switching everything to 32bit (python, wxPython, etc.), and everything is fine now.
So, I would really recommend that you use "file rect.pyd" command to determine if your module is really 64bit.

pygame not being imported

I have a really basic question, pygame isn't being recognized in Windows 7. I have ActiveState Python 2.7 and pygame-1.9.2a0.win32-py2.7.msi installed. However, a simple hello world program that imports pygame gives
Traceback (most recent call last):
File "foo.py", line 1, in <module>
import pygame
ImportError: No module named pygame
Can anyone help me with this? I am not really familiar with editing the PATH if that is what is needed, thanks.
EDIT: Is it because ActiveState is 64 bit and I'm using the 32 bit version of pygame?
Adding pygame to the path is the first thing I would try.
A really simple (and probably bad to leave it there but okay to test) way to get things running is to locate where your pygame is installed, and add it to sys.path
There is more info here: http://greeennotebook.com/2010/06/how-to-change-pythonpath-in-windows-and-ubuntu/
You can eventually add it to the windows PATH.
Ah, never mind, it appears I needed both versions of ActiveState and pygame to be 32 bit. Works now.

import gtk/glib produces ImportError: DLL load failed

I installed the latest versions of python (2.6.5), gtk+, pygtk (and friends) from their respective websites on Windows XP SP3. When you try to import gtk (or just glib for that matter), an ImportError is raised:
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import gtk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python26\lib\site-packages\gtk-2.0\gtk\__init__.py", line 38, in <module>
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 <module>
from glib._glib import *
ImportError: DLL load failed: The specified procedure could not be found.
This was working on the same machine around 6 months ago, although this time around I have re-installed. I tried different versions of the libraries but still couldn't get it to work.
There are a couple of pages out there relating to this, but not suggest a solution, and I'm unable to find one.
I got a work around this by installing the windows GTK+ runtime as indicated in this link
http://www.gramps-project.org/wiki/index.php?title=Windows_installer#Installation
Also see their page dedicated to troubleshooting import errors on windows: http://www.gramps-project.org/wiki/index.php?title=ImportError:_DLL_load_failed
I managed to solve this myself. Firstly, there can be more than one cause so this may not help everyone.
I went through the PATH system environment variable and removed all paths that pointed to old versions of gtk+ (for example, those that come packaged with applications).
Same problem, answer was to reinstall pygtk from grampy page.
It was problem of pygtk, not system or gtk.
(Before this, import pygtk works well)
I had this same exact problem on Windows 7 64. I tried installing multiple versions of python 2.6, and the all-in-one pygtk that is supposed to give you GTK+ also. This installer didn't seem to do anything. Then I installed the latest versions of GTK+ (from binary), pygtk, pycairo, and gobject (all explained on the pygtk downloads website). When I did this, I got the ImportError: DLL load failed: The specified procedure could not be found. that is given above.
The SOLUTION was to uninstall pygtk, pycairo, gobject and remove the GTK+ bin location from my path variable. Then I went here and did the first 5 steps (in that order) under "Dependencies - The Hard Way". And now it works. Note: I didn't install gramps, just the pygtk part (first 5 steps).
Some reports indicate that the trick is to import pygtk first. Have you tried that?
I have copied gtk module (site-packages: gtk-2.0, pygtk.py, cairo) to other python installation and encountered the same problem.
It was happening because I forgot to copy site-packages/pygtk.pth.

How to Make a PyMe (Python library) Run in Python 2.4 on Windows?

I want to run this library on Python 2.4 in Windows XP.
I installed the pygpgme-0.8.1.win32.exe file but got this:
>>> from pyme import core
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python24\Lib\site-packages\pyme\core.py", line 22, in ?
import pygpgme
File "C:\Python24\Lib\site-packages\pyme\pygpgme.py", line 7, in ?
import _pygpgme
ImportError: DLL load failed: The specified module could not be found.
And then this pop up comes up
---------------------------
python.exe - Unable To Locate Component
---------------------------
This application has failed to start because python25.dll was not found. Re-installing the application may fix this problem.
---------------------------
OK
Do I need to "compile" it for Python 2.4? How do I do that?
While the pygpgme project does not clearly document it, it's clear from the error message you got that their .win32.exe was indeed compiled for Python 2.5.
To compile their code for Python 2.4 (assuming they support that release!), download their sources, unpack them, open a command window, cd to the directory you unpacked their sources in, and run python setup.py install. This will probably not work unless you have the right Microsoft C compiler installed (MSVC 6.0 if I recall correctly).
It's no doubt going to be much less trouble to download, install and use Python 2.5 for Windows (it can perfectly well coexist with your current 2.4, no need to remove that). Is that a problem?

Categories