Lo-Fi Python

May 17, 2023

How to Fix Pip Install Site-Packages --user Error

While running Python version 3.8.10 today, out of the blue I saw this error attempting to pip install a package in my virtual environment:

ERROR: Cannot perform a '--user' install. User site-packages are not visible in this virtualenv.

I found a Github thread that fixed the problem! You need to update your pyvenv.cfg in order to resolve this conflict.

Here is how to fix your Python environment from Github user jawalahe:

  1. Go to the pyvenv.cfg file in the virtual environment folder.
  2. Set include-system-site-packages to true and save the change.

After completing this, my pip installs worked again and no longer returned the error.

Jan 23, 2022

How to Upgrade Requests in the Bash Console

This command can be used to upgrade your Python requests library with pip, Python's package manager. It is tailored for a PythonAnywhere environment. I suppose this command works on any Bash console, but if you're running your app with pythonanywhere, you can find the bash console here:

::
https://www.pythonanywhere.com/user/your_username/consoles/
bash console python install

Install requests with this command:

python3.8 -m pip install requests --upgrade --user

Substitute in whatever your Python version is. This command upgrades the requests library on a PythonAnywhere app. If any libraries depend on a specific version of requests, a warning appears like this one I saw for the python-unsplash library.

ERROR: python-unsplash 1.1.0 has requirement requests==2.20.0, but you'll have requests 2.27.1 which is incompatible.
Requests upgrade python library