I am running Eclipse (Indigo) with PyDev, Python 2.6 and PyWin32 (build 217, 32 bit), and having a problem that gets stranger the more I investigate.
I'm running a Python program that imports the following 3 libraries:
import win32con
import win32file
import pywintypes
win32con imports properly but win32file does not (note: win32con is a pyc and win32file is a pyd, in raw Python):
Traceback (most recent call last):
File "....\dynamic\testpywin32.py", line 2, in <module>
import win32file
ImportError: DLL load failed: The specified module could not be found.
I tried the equivalent in pure Python 2.6 (IDLE) and everything imported properly.
Comparing sys.path in IDLE and Eclipse, the only thing not in Eclipse is ['C:\Python26\Lib\idlelib']; the only extra thing Eclipse has (besides the workspace) is C:\eclipse\plugins\org.python.pydev.debug_2.2.4.2011121401\pysrc.
In addition, I went on and used the following commands right after startup, through the debugger:
sys.path = [sys.path from IDLE]
os.environ['PATH'] = [os.environ['PATH'] from IDLE]
which didn't seem to help.
What's going on here?
which windows version are you using??
i am using windows XP + pydev plugin and its works.
go to python path and try to fix the python eggs path, and press apply
Related
I need to test unity 3d app on mobile device (or emulator). I do not want to press on buttons using coordinates only, so I want to use Sikuli. I will describe steps that I have already done:
Downloaded and installed Sikuli v1.1.1
Installed java 32bit
Installed jython 2.7.0
jython added as interpreter in my project in pyCharm
sikulixapi is run
Copied Sikuli lib from appData to jython folder
Created Python file and added imports
And when I try to run project I receive this error:
D:\jython2.7.0\bin\jython.exe -Dpython.path=D:\python_projects\sikuli_test D:/python_projects/sikuli_test/test_sikuli.py
Tra**ceback (most recent call last):
File "D:/python_projects/sikuli_test/test_sikuli.py", line 1, in <module>
from sikuli import Region
File "D:\jython2.7.0\Lib\sikuli\__init__.py", line 5, in <module>
from org.sikuli.basics import Debug
ImportError: No module named sikuli
Process finished with exit code -1**
What am I doing wrong?
The following works for me:
import org.sikuli.script.SikulixForJython
before
from sikuli import *
In your jython project interpreter, set the environment variables path to where your sikuli jar is placed. That should fix it.
Also make sure to use this in your code
import org.sikuli.script.SikulixForJython
from sikuli import *
Im trying to compile Godot engine following the instructions here
When I run scons bin/godot as the tutorial says, I get the following error:
scons: Reading SConscript files ...
ImportError: cannot import name _args_from_interpreter_flags:
File "/home/grayfox/github/godot2/godot/SConstruct", line 9:
import multiprocessing
File "/usr/lib64/python2.7/multiprocessing/__init__.py", line 65:
from multiprocessing.util import SUBDEBUG, SUBWARNING
File "/usr/lib64/python2.7/multiprocessing/util.py", line 40:
from subprocess import _args_from_interpreter_flags
The SConstruct file starts this way:
EnsureSConsVersion(0,14);
import string
import os
import os.path
import glob
import sys
import methods
import multiprocessing
...
If I try to run python SConstruct I get an error complaining about missing functions defined by scons (i.e. the script fails after doing all the imports).
Commenting import multiprocessing fixes the issue but I don't want to modify that file, as I would have to revert the change if I ever make a pull request. The project is quite active so I believe this has something to do with my local configuration.
Any ideas why the script is failing to import _args_from_interpreter_flags only if I execute it via scons?
[UPDATE]
I did a fresh Gentoo install and the problem persists. I did some tests and I found this:
In a python terminal>
>>> import SCons.Script
>>> from subprocess import _args_from_interpreter_flags
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name _args_from_interpreter_flags
>>> import subprocess
>>> subprocess.__file__
'/usr/lib64/python2.7/site-packages/SCons/compat/_scons_subprocess.pyc'
But the output is different if I do this:
>>> import subprocess
>>> subprocess.__file__
'/usr/lib64/python2.7/subprocess.pyc'
So I update my question: Is this a bug? Can anybody reproduce it in other distros? If it's a bug, should I report it to Gentoo or to SCons?
[ANOTHER UPDATE]
Adding temp.extend([os.path.join(x, 'lib64') for x in prefs]) did't work, same error.
Adding print sys.path at the beginning of the compact module gives:
['/usr/lib64/python-exec/python2.7/scons-local-2.3.0',
'/usr/lib64/python-exec/python2.7/scons-local',
'/usr/lib64/python2.7/site-packages/lib32/scons-2.3.0',
'/usr/lib32/scons-2.3.0',
'/usr/local/lib32/scons-2.3.0',
'/usr/lib64/python2.7/site-packages/lib/python2.7/site-packages/scons-2.3.0',
'/usr/lib/python2.7/site-packages/scons-2.3.0',
'/usr/local/lib/python2.7/site-packages/scons-2.3.0',
'/usr/lib64/scons-2.3.0',
'/usr/lib64/python2.7/site-packages/lib32/scons',
'/usr/lib32/scons',
'/usr/local/lib32/scons',
'/usr/lib64/python2.7/site-packages/lib/python2.7/site-packages/scons',
'/usr/lib/python2.7/site-packages/scons',
'/usr/local/lib/python2.7/site-packages/scons',
'/usr/lib64/scons',
'/usr/lib64/python2.7/site-packages/RBTools-0.6-py2.7.egg',
'/usr/lib64/python27.zip',
'/usr/lib64/python2.7', #It's here, so what's the problem?
'/usr/lib64/python2.7/plat-linux2',
'/usr/lib64/python2.7/lib-tk',
'/usr/lib64/python2.7/lib-old',
'/usr/lib64/python2.7/lib-dynload',
'/usr/lib64/python2.7/site-packages',
'/usr/lib64/python2.7/site-packages/gtk-2.0',
'/usr/lib64/python2.7/site-packages/wx-2.8-gtk2-unicode']
It looks as if this isn't really a problem connected to SCons directly. You might have an alien "subprocess" module/package installed in your system. Also check out Cannot import name _args_from_interpreter_flags which seems to be related.
Based on your updated question: I tried to compile Godot on my machine (Python 2.7.3, SCons 2.3.1, Ubuntu 12.04 LTS) and it's running fine, so the problem is not related to the provided SConstruct (and its supporting build description files in subfolders). The "_scons_subprocess" module gets used only when the import of the original "subprocess.py" fails. So I suspect that the SCons start script sets up a wrong sys.path, which may happen under 64bit (see issue http://scons.tigris.org/issues/show_bug.cgi?id=2657 ).
After you added "temp.extend([os.path.join(x, 'lib64') for x in prefs])", your "print sys.path" statement shows paths like "/usr/lib64/python-exec" in its output. A Google search turned up the page http://forums.gentoo.org/viewtopic-t-985402-start-0.html for me. It describes an issue with Gentoo, where programs are installed as links to pip. Please follow the given advice and see if this fixes your problem.
It's a bug in Gentoo's scons-2.3.0 and scons-2.3.1 ebuilds (see bug report). It has been fixed in versions 2.3.1-r1 and higher.
I have downloaded the module from sourceforge. audiere-1.9.4-win32
The unzipped folder has the following folders:
-bin
-bindings
-doc
-include
-lib
The Bindings folder includes a file called audiere.pyd and an installation instruction which says:
Into the Windows distribution of Python 2.2:
Copy audiere.dll and audiere.pyd into your Python22 directory (or
perhaps Python22/DLLs, depending on your system).
I tried copying both files to:
-python 2.7/
-python 2.7/DLL
-python 2.7 /LIb/site-packages/ directory but
import audiere
still gives a import error:
Traceback (most recent call last):
File "", line 1, in
import audiere
ImportError: DLL load failed: The specified module could not be found.
I am sure this is nothing to do with python 2.2 versus python 2.7 because people have successfully used audiere on 2.7 without any modification.
How do I install audiere on windows 7.
You can try to use pyglet. This library has the capability to play using external library called Avbin.
Simple example of how to use:
import pyglet
music = pyglet.resource.media('music.mp3')
music.play()
pyglet.app.run()
If you have some problems with avbin, put the dll in the same directory of your code and insert this two lines before "pyglet.resource.media('music.mp3')":
pyglet.lib.load_library('avbin')
pyglet.have_avbin=True
I have installed Python 2.6.7 in $HOME/local of a machine which already has a default Python in /usr (I don't have admin access on this machine). The default Python is compiled in 32bits and my local installation is a 64bits. For some unknown reasons my local Python library (which I call as an embedded python interpreter from within a C program) search for the modules in the default (wrong) installation.
This is the result of "import random"
Traceback (most recent call last):
File "test.py", line 3, in <module>
import random
File "/tmp/work/mdorier1/local/lib/python2.6/random.py", line 45, in <module>
from math import log as _log, exp as _exp, pi as _pi, e as _e, ceil as _ceil
ImportError: /usr/lib/python2.6/lib-dynload/math.so: wrong ELF class: ELFCLASS32
As you can see, the import statement correctly search "random.py" in the local installation of Python, but the import statement in random.py go search for math.so in the wrong location, which ends in an error since the default location has 32 bits modules.
I guessed there is a problem with an environment variable, and I tried
import sys
sys.path
to get
['/tmp/work/mdorier1/local/lib/python26.zip',
'/tmp/work/mdorier1/local/lib/python2.6',
'/tmp/work/mdorier1/local/lib/python2.6/plat-linux2',
'/tmp/work/mdorier1/local/lib/python2.6/lib-tk',
'/tmp/work/mdorier1/local/lib/python2.6/lib-old',
'/usr/lib/python2.6/lib-dynload',
'/tmp/work/mdorier1/local/lib/python2.6/site-packages']
I noticed that on of the paths indeed points to the default installation of Python. My questions thus are:
- Why this path shows up here, as the local installation has nothing to do with the default one?
- How do I change it (in a clean and permanent way)? This path should be the path to lib-dynload in the local installation instead.
Thanks
You probably don't have your Python's bin directory in the PATH variable before the system Python.
Or perhaps you simply compiled your Python incorrectly and did not use:
./configure --prefix=/tmp/work/mdorier1/local
so now it thinks that its files are somewhere else.
when i write import win32print in my python command line (IDLE) it works fine and it is imported...
but when i write import win32print in my py file then it gives an error
says no module named win32print
why am i not able to load the module when writing the same statement in a py script...im using windows XP
Check if you are running on the same installation. I'd do that by looking the path:
import sys
print sys.path
And compare the output on IDLE and when you run the .py