-
Notifications
You must be signed in to change notification settings - Fork 788
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
pywintypes module not found in virtualenv #1455
Comments
That's odd. Note that there should be a |
Some more info:
|
Is this still open? I have the same issue - within a virtualenv, it can't find the module. After deactivation, it can. (with python 3.6) |
pip uninstall followed by pip install (in the virtual environment) does the trick for me |
Could you post the steps to reproduce? |
All who are encountering the error, please post all the details:
Actually, post all the commands used and their outputs. For the service question: what does |
This is odd - I just created a new virtualenv from scratch, pip installed just pywin32, and it worked. Went back to the previous virtualenv, uninstalled and reinstalled pywin32, and now it works there as well... |
So this actually outputs blank, Also @eranzim can you post your code? If I could work with your's it means my issue might be a different one, which means this one could be closed and newly open more specific issue EDIT: By mistake my entire post was inside the quote 😅 |
@yuval9313 The code that didn't work was simply |
@yuval9313: What about |
I played very little with PyWin32 services, but I imagine they are started by SYSTEM. Hmm you should write the contents of sys.executable, sys.path, site.getsitepackages(), site.getusersitepackages() in a file, before importing win32api and look at the file after the service fails. Also, do the same thing before by executing the script manually. |
Further, services aren't going to have the full user environment even when configured to run as a different user. The most common problem I've found is simply that the PATH isn't what you expect, so the DLLs aren't found (or in strange edge cases, the wrong ones are found). This is exactly why the .exe installer puts the DLLs into system32, and why pip installed pywin32s are always going to have issues in these kinds of contexts. |
You were right! Although, now there is another issue which is more relevant to the title: So, what now? how come when EDIT:So I found out that the quick and easy fix is just to install pywin32 outside of venv (on the global interpeter), I'm sorry for anyone who find this solution unsettling but since you wish to change your PC/Server/Whatever, its seems reasonable.Thank you @CristiFati and @mhammond for the attempts to find a solution. |
There's a |
Perhaps we should file a feature request with the virtualenv group?
…On Wed, Apr 22, 2020 at 9:11 PM Mark Hammond ***@***.***> wrote:
how come when pywintypes38.dll is recognized the library is not?
There's a pywintypes.py that must be on sys.path
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1455 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEZOBOXCTFBCAQTESBFE33RN6WWBANCNFSM4J6LE3VA>
.
|
This is strange. #1442, should take care of this particular case. Anyway, the original issue reported here doesn't seem to reproduce anymore. Probably it would be OK to create anew one (which only affects services?) I will take a look (give a shot), but only over the weekend. |
TBH, I don't think virtualenv is the correct tool to use for services - the stand alone server should be use. Same thing for implementing COM objects which should be made available to all users, such as shell extensions etc. |
To summarize: a simple The service problem remains (unfortunately I didn't have the time to confirm / infirm it). Probably this issue should be renamed (and the description changed) to reflect reality, or simply closed and another one open. In any case, if encountering any problems, please start from a clean initial environment! |
I agree, OP has been (at least should be) resolved.
Paths and services issues are replicated in other stories as well. Like in #1399 and #1865 (comment) (and many old closed issues with less details) |
Hi!
I pip-installed pywin32 on my machine, and everything works fine. I tried it in a virtualenv, and I get this error when importing pywintypes:
ModuleNotFoundError: No module named 'pywintypes'
I should also note that
pip show pywin32
shows it is installed (also inside the virtualenv), and the dll does exist inside...\myvenv\Lib\site-packages\pywin32-227-py3.8-win-amd64.egg\pywin32_system32\pywintypes38.dll
Python 3.8.0 64-bit on Windows 10 x64
pywin32 227
virtualenv 16.7.9
Possibly related: #1327 (though it seems a different issue to me)
Thanks!!
The text was updated successfully, but these errors were encountered: