Fix the Exception “Could not install packages due to an EnvironmentError: [Errno 13] Permission denied”

Python has given a chance to programmers to develop applications and websites according to a way that makes them attractive to reach users. Not only programmers are using it, but there are beginners as well who are trying numerous projects to follow the footstep of the programmers. It is obvious to get the error message when you are trying projects. You may encounter the error “Could not install packages due to an EnvironmentError: [Errno 13] Permission denied”.

Python has many libraries; this error is the library error. Don’t worry when the error shows up. We are going to guide you on how to fix it. Have a look at how the errors occur.

How the error shows up

You get the error warning when trying to install Python packages through the pip command. This is what you get in return

Could not install packages due to an EnvironmentError: [Errno 13] Permission denied:
'/Library/Python/2.7/site-packages/pip-18.0-py2.7.egg/EGG-INFO/PKG-INFO'
Consider using the `--user` option or check the permissions.

Now you get the concept of how you land up in trouble. Let’s figure out the way to remove the exception

Solutions to fix the error “Could not install packages due to an EnvironmentError: [Errno 13] Permission denied”

We have a few sure short solutions that can fix the error efficiently. Follow the solutions

Solution 1 – Place the -user at the end

The simplest yet effective solution to fix the error is to place the -user at the end of the command. Follow the below command

pip3 install package_name --user

with this, you can remove the exception.

Solution 2 – The pip update

Another way to handle the exception is to update the pip. You just need to follow the below command to update the pip

sudo pip install --upgrade pip

You need to run pip but as an executable. For this, follow the command

python3.6 -m pip install <package>

Solution 3 – Create an Isolated Virtual Environment

To resolve the error warning, you need to create isolated virtual environments. In order to create it in Python3+, use the below command

virtualenv enviroment_name -p python3

Once done, you just need to activate it. To activate, follow this command

source enviroment_name/bin/activate

Next, you should install the project’s dependencies in the virtual environment with the help of pip. For this, you need to implement the below command

pip install package_name

Change the ownership setting

To fix the permission error warning, you need to visit /Library/Python/2.7/site-packages/… to find the directory having elevated or root permission as well as rm -rf yourpackages. You either need to reinstall the packages or force ownership to change in order to have permission.  For this, follow the command below

chown -R owner:group /path/to/anaconda

Conclusion

We shed light on the error “Could not install packages due to an EnvironmentError: [Errno 13] Permission denied”. A few effective solutions are shared in the post to help you get rid of the error.

I wish you luck! Happy Coding!

Reference Source: https://bencipher.medium.com/how-to-fix-error-could-not-install-packages-due-to-an-environmenterror-errno-13-permission-9459f7086f55

https://sqa.stackexchange.com/questions/37707/error-could-not-install-packages-due-to-an-environmenterror-errno-13-permis

Leave a Reply

Your email address will not be published. Required fields are marked *