The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Python
 win32api

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
maciejb09866 Posted - 04/25/2021 : 06:02:28 AM
Hello,
I'd like to use a following code:
from win32com.client import Dispatch 

I tried to install several packages (pywin32, pypiwin32,...) but I always got an issue with win32api:
ModuleNotFoundError: No module named 'win32api'

When I try to install win32api in manager I have following problem:

ERROR: Could not find a version that satisfies the requirement win32api (from versions: none)
ERROR: No matching distribution found for win32api

Any help would be appreciated.
4   L A T E S T    R E P L I E S    (Newest First)
maciejb09866 Posted - 04/26/2021 : 11:14:02 AM
Thank you! Now it works fine.
Chris D Posted - 04/26/2021 : 10:55:36 AM
Hi,

This seems to be a solution specific to the built-in interpreter in Origin:


import os
import sys
os.add_dll_directory('C:\\ProgramData\\OriginLab\\PyPackage\\Py38\\64bit\\pywin32_system32')
sys.path.append('C:\\ProgramData\\OriginLab\\PyPackage\\Py38\\64bit\\win32')
sys.path.append('C:\\ProgramData\\OriginLab\\PyPackage\\Py38\\64bit\\win32\\lib')

from win32com.client import Dispatch 


Edit:
An explanation...

The pywin32 package has a "post installation" script that must be run as an administrator because it copies two DLLs to the `C:\WINDOWS\system32` folder. As well, it modifies your `Path` environmental variable. It would be difficult to run that post install script as admin because not everyone has admin access on their PC. It would be a hassle.

So, this line in the code above prevents the need to copy the DLLs by pointing the interpreter to look at the original source of the DLLs:

os.add_dll_directory('C:\\ProgramData\\OriginLab\\PyPackage\\Py38\\64bit\\pywin32_system32')


Now, if you modified your actual Path environmental variable for an Origin-embedded specific package, it may cause problems with an external Python installation. So, instead of worrying about modifying your actual Path variable, we use these two lines that temporary modify it for the embedded instance of Python only:

sys.path.append('C:\\ProgramData\\OriginLab\\PyPackage\\Py38\\64bit\\win32')
sys.path.append('C:\\ProgramData\\OriginLab\\PyPackage\\Py38\\64bit\\win32\\lib')


Finally, what is this path: C:\ProgramData\OriginLab\PyPackage\Py38\64bit ??? That is where Origin install packages when you install them from within the product.

Thanks,
Chris Drozdowski
Originlab Technical Support
maciejb09866 Posted - 04/26/2021 : 10:00:53 AM
Thank you for your answer.
Sorry, but I was not precisely in my previous message.
My intention is to access different software via embedded Python in Origin2021 (with the use of win32com.client). I installed pywin32 in python packages manager in Origin, but I am not able to succesfully use win32com.client due to:
ModuleNotFoundError: No module named 'win32api'
Chris D Posted - 04/26/2021 : 08:29:20 AM
If you are trying to access Origin via Python, please install the originpro package (https://pypi.org/project/originpro/). It is supported in Origin 2021. There is also the OriginExt package (https://pypi.org/project/OriginExt/) which is a lower level API.


Otherwise, we don't support other methods of accessing Origin such as via the methods you are inquiring about.

~Chris

Thanks,
Chris Drozdowski
Originlab Technical Support

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000