473,385 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to import win32com.client though it's installed?

Hello,

I'm trying to use the in32com.client for writing into Excel with Dispatch() (on a windows machine using python 2.7.1). I downloaded pywin from http://sourceforge.net/projects/pywin32/ into the C:\Python27 folder and hit both setup.py and pywin32_postinstall.py

I'm running my python program in the windows command prompter cmd. But it won't run because it cannot import the win32com.client.
When prompting or running my program containing the import:
python import win32.client

I keep getting the following error message:
python: can't open file ... [Errno 2] no such file or directory

I've been trying in different combinations of 'import' 'python import', file name, complete file loaction, but nothing works. I merely keep getting error messages alternating from English to German (which is the language setting for the computer)

Any idea what the problem could be? Should I try a different pywin version? Or save it differentlx? Am I not doing the installation properly?

Thanks for any help.

Amelie
excel = win32com.client.Dispatch('Excel.Application')
Dec 22 '10 #1
3 15191
dwblas
626 Expert 512MB
Try explicitly setting the path to the .exe's directory.
Expand|Select|Wrap|Line Numbers
  1. import sys
  2. sys.path.append("path/to/exe")
  3. import win32.client
  4. # and/or
  5. import win32com.client 
If that doesn't help then you have not installed it correctly, so install it again this time with setup.py only (which may be a good idea anyway).
Dec 22 '10 #2
I've gotten a bit further, but still couldn't get it to work. I'm pretty new to programming, so I don't quite know where to go I've I have a suspicion
I added the path as you suggested and I also reinstalled the zip folder, unzipped, ran setup.py (only). I installed it where the default setting put it.

Expand|Select|Wrap|Line Numbers
  1. import sys
  2. sys.path.append("C:\\Python27\\pywin32-214\\pywin32-214\\com")
  3. import win32com
I am now getting a new error message:

Z:\testpython>python version1.py
Traceback most recent call last>:
File "version1.py", line 5, in <module>
import win32.com
File "C:\Python27\pywin32-214\pywin32-214\com\win32com\__init__.py", line 5, in <module>
import win32api, sys, os
ImportError: No module named win32api

Is that caused by the location of the __init__.py being unexpected? Should I move the content or the win3232-214 folder into the parent folder, Python27? Or should I modify the path in the __init__.py file (that seems a bit fishy...)?

Thanks again,

Amelie
Dec 23 '10 #3
Help!
I am still stuck on this (I thought I could use xlrd/xlwt instead, but now have to return to Dispatch).

I went through the Installation Problems on http://www.python.net/crew/mhammond/...nProblems.html. As described in the first paragraph, I do have 2 versions (and am no administrator). I deleted the version in C:\Python27 but whenever I startup IDLE it re-creates it.

It seems like no one else is having this problem (most people just seem forget to install it), so if you have ANY idea, please let me know. I really really need help on this.
Jan 31 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Justin Stockton | last post by:
I recently upgraded from ActivePython 2.2.2 to ActivePython 2.3.2 and I'm running into an issue importing the win32com.client module. Before installing the new version, I made sure to properly...
0
by: selwyn | last post by:
hi, this is my first foray into the mysteries of COM and dlls, so please humour me. I have been provided with a dll interface for a connection to a web-server. The documentation provided is...
4
by: erikpaulmiller | last post by:
I am trying to open up a blank email message by using the mailto: url. I have noticed that it will work for any value under 2013 characters, but once I have a To: list longer than 2014 chars then I...
0
by: Kenneth Keeley | last post by:
Hi, I have been working on a Login page that uses ADSI to authenicate the users. I had this all working on my test system and on a second system connected to the live domain. Now it will only work...
0
by: Math | last post by:
Hello python people, Can you help me out please. I get the folllowing Error while trying to build a installer with the Distutils module:...
4
by: mirandacascade | last post by:
O/S : Win2K vsn of Python: 2.4 Hoping to find information that provide information about error messages being encountered. Pythonwin session: Traceback (most recent call last): File...
12
by: vithi | last post by:
Hi Any one tell me where I can get (or download) python modules win32com or win32com.client because I have to use "Dispatch" thanks
4
by: vithi | last post by:
Hi' I am trying to launch an application. When I try like that When I try like that Excel is opening import win32com.client object = win32com.client.Dispatch("Excel.Application") object.Visible...
3
MTEXX
by: MTEXX | last post by:
I have used the Windows Service template to create, well, a Windows Service. It starts, stops, pauses etc. Works great. I added an Setup project. It builds an .msi (and .exe) file. I thought I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.