Skip to content
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

Workaround for virtual environments (VirtualEnv) #1442

merged 4 commits into from Nov 13, 2019


Copy link

CristiFati commented Nov 11, 2019

pip installing v226 in a (VirtualEnv based) virtual environment (not sure f this is an officially supported configuration) makes it unusable:

[prompt]> ".\venv_py_064_030800\Scripts\python.exe" -m pip list
Fatal Python error: init_import_size: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
  File "e:\Work\Dev\StackOverflow\q058805040\venv_py_064_030800\lib\", line 769, in <module>
  File "e:\Work\Dev\StackOverflow\q058805040\venv_py_064_030800\lib\", line 746, in main
    paths_in_sys = addsitepackages(paths_in_sys)
  File "e:\Work\Dev\StackOverflow\q058805040\venv_py_064_030800\lib\", line 279, in addsitepackages
    addsitedir(sitedir, known_paths)
  File "e:\Work\Dev\StackOverflow\q058805040\venv_py_064_030800\lib\", line 202, in addsitedir
    addpackage(sitedir, name, known_paths)
  File "e:\Work\Dev\StackOverflow\q058805040\venv_py_064_030800\lib\", line 170, in addpackage
  File "<string>", line 1, in <module>
  File "e:\Work\Dev\StackOverflow\q058805040\venv_py_064_030800\lib\site-packages\win32\lib\", line 14, in <module>
    for maybe in site.getsitepackages():
AttributeError: partially initialized module 'site' has no attribute 'getsitepackages' (most likely due to a circular import)

Just to make things clear: there's nothing wrong with PyWin32, it's just a fix applied on PyWin32's side to work around a VirtualEnv bug.

More details on [SO]: PyWin32 (226) and virtual environments (@CristiFati's answer).

@CristiFati CristiFati changed the title Workaround for virtual environments (VEnv) Workaround for virtual environments (VirtualEnv) Nov 11, 2019
CristiFati added 2 commits Nov 11, 2019
@mhammond mhammond merged commit cc014e3 into mhammond:master Nov 13, 2019
1 check failed
1 check failed
continuous-integration/appveyor/pr AppVeyor build failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.