I'm trying to add win32com to Python 2.7. After looking at this, I added the directory with the _init file (Python27\Lib\site-packages\win32com) but I still get it. I went so far as to try to add a bunch of different folders to the path that seem to have to deal with win32com but I still get the error. If it knows where the file is and I added that folder to PYTHONPATH, why is this happening? I'm using PyDev with Eclipse Juno. My code:
import win32com.client
print("hello world")
when I try to run this, i get this error
Traceback (most recent call last):
File "C:\Users\Daniel\EclipseWorkspace\PhotoScript\src\scriptLaunch.py", line 1, in <module>
import win32com.client
File "C:\Python27\Lib\site-packages\win32com\__init__.py", line 5, in <module>
import win32api, sys, os
ImportError: DLL load failed: The specified module could not be found.
in my case typing in cmd:
python C:\Python27\Scripts\pywin32_postinstall.py -install
cmd Windows
I hope this helps
Try installing ActivePython, it includes win32com:
The Python for Windows Extensions (PyWin32 version 214).
The interface to the Win32 API (win32api).
The interfaces to Win32 COM (win32com and win32comext).
The Pythonwin Development Environment.
*ActivePython is fully binary compatible with python.org Python builds to ensure that 3rd-party binary extensions just work*
Try to install python for windows extensions:
https://sourceforge.net/projects/pywin32/files/pywin32/Build%20210/
Related
I am trying to import a python module from a certain folder. This is the code:
import sys
sys.path.append(r"C:\path\to\module_foobar")
import foobar
In a miniconda env with all prerequisites installed (python 3.10 and numpy), I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed while importing foobar: The specified procedure could not be found.
But with the system python in cmd, the same code works.
Tried adding the path to system path variable as well as specifying it in a custom .pth file in the site-packages folder of the miniconda environment.
Tried running dependencywalker on the .pyd file of the package and it says that a bunch of MS C++ Redistributeable dll files seem to be missing. Tried repairing those to no avail.
What on earth could be wrong?
Im a trying to build a COM server in Python. I have downloaded and installed Pywin32 (I use 32-bit version of Python 3.4.1, so I downloaded and installed pywin32 for this version).
Now, in order to import pythoncom in IDLE, I need to have two .dll files readily accessible:
-pythoncom.dll
-pywintypes.dll
Both .dll files are in the following directory:
C:\Python34\Lib\site-packages\pywin32_system32
When I give the import statement in IDLE, I get the following error:
Traceback (most recent call last):
File "", line 1, in
import pythoncom
File "C:\Python34\lib\site-packages\pythoncom.py", line 2, in
import pywintypes
ImportError: No module named 'pywintypes'
I reinstalled pywin32, but it still doesn't fix it.
I am now trying to add C:\Python34\Lib\site-packages\pywin32_system32 to my PATH directory, but it doesn’t work. I am trying this via:
os.environ["PATH"] += os.pathsep + C:\Python34\Lib\site-packages\pywin32_system32
I then get the following message:
The syntax of the command is incorrect.
What error am I making in the syntax above? How can I fix this (i.e. how can I add C:\Python34\lib\site-packages\pythoncom.py to my PATH environment)?
I'm new to python.
I'm working in windows environment. mostly win7.
My machine is win7 32bit also.
I downloaded the wmi module and used the .exe to install it.
when I try and 'import wmi', i get an error:
Traceback (most recent call last):
File "<pyshell#5>", line 1, in <module>
import wmi
File "C:\Python33\lib\wmi.py", line 88, in <module>
from win32com.client import GetObject, Dispatch
ImportError: No module named 'win32com'
How can I solve this? Does win7 compliant with this module?
Regards
download WMI-1.4.9.win32.exe from https://pypi.python.org/pypi/WMI/ and it will resolve your problem
Instead you can also install win32com which would resolve the issue.
To install win32com use:
pip install pypiwin32
What worked for me is:
i downloaded the source named: WMI-1.4.9.zip from https://pypi.python.org/pypi/WMI/
Extracted all files from that zip file and saved it in a folder named: WMI-1.4.9 and then copied that folder to C:\Python27\Lib\site-packages.
After that I navigated to that folder C:\Python27\Lib\site-packages\WMI-1.4.9 and did a shift + right click -> Open Command line here and ran: python setup.py install
That's it, after that it worked for me like charm. No issues.
p.s - While installing exe I had some weird Access Denied errors, I tried by running the exe as Administrator even then I could get through it. Hence that didn't at all work for me.
Also I had pywin32 installed from here:
http://sourceforge.net/projects/pywin32/files/ (select the correct file - 'bittedness' and python version wise)
I installed wmi with the installer here http://timgolden.me.uk/python/wmi/index.html
but I can't get the module to import.
Here is my code:
import wmi
c=wmi.WMI()
for os in c.Win32_OperatingSystem():
print(os.Caption)
and here is the error:
Traceback (most recent call last):
File "C:/Python33/Programs/WMI trial.py", line 1, in <module>
import wmi
File "C:\Python33\lib\site-packages\wmi.py", line 88, in <module>
from win32com.client import GetObject, Dispatch
ImportError: No module named 'win32com'
Any idea why this isn't working? I have a 64 bit system but that hasn't affected running 32 bit python at all.
Any help is greatly appreciated!
you are missing the 'Python For Windows Extensions' (pywin32).
WMI module requires pywin32.
run the appropriate installer for pywin32, then try WMI again.
The "No module named 'win32com'" error is because it can't find the winm32com module (which is installed as part of pywin32 package.)
What worked for me is:
i downloaded the source named: WMI-1.4.9.zip from https://pypi.python.org/pypi/WMI/
Extracted all files from that zip file and saved it in a folder named: WMI-1.4.9 and then copied that folder to C:\Python27\Lib\site-packages.
After that I navigated to that folder C:\Python27\Lib\site-packages\WMI-1.4.9 and did a shift + right click -> Open Command line here and ran: python setup.py install
That's it, after that it worked for me like charm. No issues.
p.s - While installing exe I had some weird Access Denied errors, I tried by running the exe as Administrator even then I could get through it. Hence that didn't at all work for me.
Edit:
Also I had pywin32 installed from here:
http://sourceforge.net/projects/pywin32/files/ (select the correct file - 'bittedness' and python version wise)
When I try to import the slycot module in spyder (version 2.2), I get the following error:
RuntimeError: module compiled against API version 7 but this version of numpy is 6
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Applications/Spyder.app/Contents/Resources/lib/python2.7/slycot/__init__.py",
line 4, in <module>
from slycot.analysis import ab01nd,ab05md,ab05nd,ab07nd,ab08nd, ab09ad
File "/Applications/Spyder.app/Contents/Resources/lib/python2.7/slycot/analysis.py",
line 21, in <module>
from slycot import _wrapper
ImportError: numpy.core.multiarray failed to import
Now, when I import slycot in the python shell through my terminal, there are no problems at all. I think the reason why there are no problems through the terminal, is that I recently installed numpy 1.7.1. Spyder on the other hand still uses numpy 1.6.2.,hence the error.
I tried to change the numpy version in spyder, but so far that didn't work.
When I change the numpy(6) folder in my spyder lib with the recently installed numpy(7), I get the following error (in spyder):
ImportError: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python intepreter from there.
What is the best way to solve this error?
Thanks in advance.
(Spyder dev here) At the moment it's not possible for the user to install anything inside the app. I guess you moved your slycot module from another interpreter to our App (because of the numpy error you mention).
The right way to use different modules not present in the app, is to change the path of your interpreter in:
Tools > Preferences > Console > Advanced settings > Python executable
If you installed slycot using your system Python, you have to select
/usr/bin/python