AttributeError: module 'site' has no attribute 'getsitepackages'
See original GitHub issueIssue 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.
pipenv --venv
$HOME/.local/share/virtualenvs/$hash
ls -l $HOME/.local/share/virtualenvs/$hash/lib/python3.7 | grep site.py
-rw-rw-r-- 1 $user $user 28389 Jun 6 07:13 site.py
The aforementioned site.py does not have getsitepackages() method.
The other modules refer to the modules installed in python environment.
E.g. os.py
ls -l $HOME/.local/share/virtualenvs/$hash/lib/python3.7 | grep os.py
lrwxrwxrwx 1 $user $user 51 Jun 6 07:13 os.py -> /usr/local/pyenv/versions/3.7.3/lib/python3.7/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()"
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
python - module 'site' has no attribute 'getusersitepackages'
Try running site.USER_SITE(). if you get an answer, it might mean that the site package is of an older version since the docs...
Read more >Package fails to install in virtual env, can't find anything in the ...
getsitepackages(): AttributeError: module 'site' has no attribute 'getsitepackages' ---------------------------------------- ERROR: Command ...
Read more >Chilkat2 Python Module for Linux Install Instructions
AttributeError: module 'site' has no attribute 'getsitepackages'. This can happen in a virtualenv because site.py does not have getusersitepackages().
Read more >pip install arcgis - Esri Community
... in <module> File "/tmp/pip-install-o_gaembh/arcgis/setup.py", ... AttributeError: module 'site' has no attribute 'getsitepackages'
Read more >site — Site-specific configuration hook — Python 3.11.1 ...
In that case, this module can be safely imported with no automatic modifications to the module search path or additions to the builtins....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
Delete the virtual environment, change the pywin32 environment in your Pipfile to “==225”, and then run pipenv update. If you don’t have a pywin32 requirement, it’s probably required by another required package. Just add pywin32 with the “==225” version into your Pipfile.