-
Notifications
You must be signed in to change notification settings - Fork 808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import problem on a fresh AWS EC2 #1803
Comments
Sorry for the delay here:
That script is pywin32_postinstall.py - I'll try and remember to update the docs to make that clearer. It will try and copy to system32, but unless this is done from an elevated command prompt it will not be able to, in which case it will copy it next to pythonXX.dll. That almost certainly could be improved for virtual envs and I'd welcome PRs - see also #1794 which might make life a bit better and some user's report it does help when running in a virtualenv, and may even help this exact case. If you can test the artifacts from that PR I'd welcome any feedback you have. |
I tried this on the AWS EC2 (using a python --version
Python 3.9.9
md artifact
cd artifact
python -m venv .venv
.venv\Scripts\activate
pip install pywin32-302.1-cp39-cp39-win_amd64.whl
python -c "import win32com.client" and, no error popup! Is there some way in the Python REPL that I can show I'm running the correct |
@jrobbins-LiveData |
(Note: I've read the entry point caveat, but am still in need of some guidance.)
On a freshly created AWS EC2 (running a Windows_Server-2019-English-Full-Base-2021.11.10 AMI), there's a folder in the System Path that has an older version of Python DLLs, including
pythoncom39.dll
. But I didn't know that, at first.I installed Python 3.9.9 using pyenv-win. I then ran the following commands:
I expected no problem from the
import win32com.client
. But instead, this popped upI started to investigate, and saw this
And in the
C:/Program Files/Amazon/cfn-bootstrap
folderHere are the "details" of pythoncom39.dll in the
cfn-bootstrap
folderThe question I have is centered on the Python virtual environment. Since the virtual environment puts its
Scripts
folder at the head of the PathI was expecting to be protected from stray Python files outside my project. The
pywin32
README.md saysBut I don't see the "post_install" script documented above. Does that script know about virtual environments? Would it copy the two DLLs (
pythoncom39.dll
andpywintypes39.dll
) fromsite-packages\
pywin32_system32into my
.venv\Scripts` folder? I ask, because I don't want to put things in the global system32 folder.Also, the "Entry Point Not Found" popup happens here. If the load algorithm could be made virtual environment aware, perhaps it could explicitly check in
site-packages\
pywin32_system32` before letting the Windows Path burst the bubble of the virtual environment?I noticed that after letting Windows look elsewhere, there this subsequent check. What is the rationale for this code coming later? If there's a virtual environment that it is "active", tested by checking the path, it seems like it would be better to find the DLLs in its
site-packages\
pywin32_system32` , than on the System Path.Anyway, I was hoping for a bit of discussion about this, or pointers to reading material if it has all be discussed before.
I'll also open an issue with AWS, because I don't understand why they left this folder (in the Path, no less), causing problems with a fresh virtual environment install of
pywin32
.Python 3.9.9 (tags/v3.9.9:ccb0e6a, Nov 15 2021, 18:08:50) [MSC v.1929 64 bit (AMD64)] on win32
pywin32==302
The text was updated successfully, but these errors were encountered: