How to solve Could not install packages due to an EnvironmentError in Python?
Here at TheQuickBlog, we share information that helps you solve problems that may be tiny or big. This time in our blog we have the solution for a small error which we see in python.
Python Pip Error: Could not install packages due to an EnvronmentError
This usually happens when pip is unable to fetch the packages from its online repository. This also happens when pip is unable to install the packages from the local cache. So, in that case, all you need to do is tell the pip installer to set the environment as Home. Doing this it will find your home directory, download the packages in your location, and install it.
First, upgrade pip referencing your home directory:
sudo -H pip3 install –upgrade pip
Then install the package you were having an issue before:
sudo -H pip3 install numpy
The -H (HOME) option with sudo sets the HOME environment variable to the home directory of the target user (root by default). By default, sudo does not modify HOME.