-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
AttributeError: module 'site' has no attribute 'getsitepackages' #3824
Comments
It is an issue with Close it for now |
This now breaks pywin32 installation, starting from pywin32==226. :( |
This started happening today.
|
Delete the virtual environment, change the pywin32 environment in your Pipfile to "==225", and then run pipenv update. |
I've gotten this issue on Python 3.7.0, Windows 10, in a virtualenv. As a workaround that seems to be holding, outside of the virtualenv, I did:
Then I simply edited the site.py in my virtualenv, and added the missing function:
It's a hacky workaround, but hopefully this helps someone else. |
work for me def getsitepackages():
return ['C:\\Users\\***\\AppData\\Local\\Programs\\Python\\Python37', 'C:\\Users\\***\\.virtualenvs\\Wolfram-OchuDyJ5\\Lib\\site-packages'] |
Happened to me on my windows CI too : Fatal Python error: initsite: Failed to import the site module Traceback (most recent call last): File "c:\\users\\circleci\\.virtualenvs\\project-ohnhamvy\\lib\\site.py", line 769, in main() File "c:\\users\\circleci\\.virtualenvs\\project-ohnhamvy\\lib\\site.py", line 746, in main paths_in_sys = addsitepackages(paths_in_sys) File "c:\\users\\circleci\\.virtualenvs\\project-ohnhamvy\\lib\\site.py", line 279, in addsitepackages addsitedir(sitedir, known_paths) File "c:\\users\\circleci\\.virtualenvs\\project-ohnhamvy\\lib\\site.py", line 202, in addsitedir addpackage(sitedir, name, known_paths) File "c:\\users\\circleci\\.virtualenvs\\project-ohnhamvy\\lib\\site.py", line 170, in addpackage exec(line) File "", line 1, in File "c:\\users\\circleci\\.virtualenvs\\project-ohnhamvy\\lib\\site-packages\\win32\\lib\\pywin32_bootstrap.py", line 14, in for maybe in site.getsitepackages():', "AttributeError: module 'site' has no attribute 'getsitepackages'" We don't have pywin32 as a direct dependency and I don't think |
Thanks @maludwig. Your work around worked well. Hope there's a long term solution soon cause I have a lot of different virtual environments. 😭 |
I received this same error message with pyInstaller package. The reason is because I was from inside a virtualenv. |
For those (like me) living under a rock: This was fixed in virtualenv 20.0+, and upgrading to pipenv 2023.2.18+ will pull the fixed virtualenv version. You then have to re-create the pipenv environments. |
Issue description
python version 3.7.3
pipenv version 2018.11.26
When I try to use site.py#getsitepackages() in pipenv environment, the below error occurrs.
AttributeError: module 'site' has no attribute 'getsitepackages'
When I use the same module in pip environment, the error does not occur.
The cause is probably that pipenv doesn't refer site.py installed in python environment.
I checked the installed directory.
The aforementioned site.py does not have getsitepackages() method.
The other modules refer to the modules installed in python environment.
E.g.
os.py
Expected result
Even in pipenv environment, site.py#getsitepackages() method is available.
Steps to replicate
Install python3.7.3
Install pipenv by pip
Run the below
pipenv run python -c "import site; site.getsitepackages()"
The text was updated successfully, but these errors were encountered: