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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Python
 win32api
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

maciejb09866

3 Posts

Posted - 04/25/2021 :  06:02:28 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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.

Chris D

428 Posts

Posted - 04/26/2021 :  08:29:20 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

maciejb09866

3 Posts

Posted - 04/26/2021 :  10:00:53 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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'
Go to Top of Page

Chris D

428 Posts

Posted - 04/26/2021 :  10:55:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

maciejb09866

3 Posts

Posted - 04/26/2021 :  11:14:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you! Now it works fine.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000