'PyCharm error: [Errno 13] Permission denied

I am using PyCharm for executing my Python programs. Today, I had tried updating all the packages using Project Interpreter. I received the following error in the process:

error: [Errno 13] Permission denied

enter image description here

After which none of my Python libraries are shown in Project Interpreter list.

I am using PyCharm Community Edition 2016.2.3 in Mac OS X 10.11.6.



Solution 1:[1]

It looks like you need to give your interpretter root permissions. There is a tutorial here on how to do this

Solution 2:[2]

The PermissionError: [errno 13] permission denied error occurs when you try to access a file from Python without having the necessary permissions. In your case the file (or directory ???) of interest is /var/folders/2k/_1tccbln53165lgvzvzt3b480000gp/T/tmprqbtrpspycharm-management/setuptools-18.1. You might want to use chmod or chown to change access permissions to it.

Solution 3:[3]

  1. sudo visudo -f /etc/sudoers.d/python

  2. inside the /etc/sudoers.d/python you just created enter these details in the given format <current_username> <hostname> = (root) NOPASSWD: <full path to python> ie mostly you might have creating a virtual env in pycharm when you start a project. so in that you would find a bin folder. inside which you will find many python virtual interpreters(mention that absolute path ex /home/<project_foldername>/bin/python).

  3. anywhere you can create shell script python-sudo.sh

  4. inside python-sudo.sh mention like this #!/bin/bash sudo <same_path_you_given_in_"/etc/sudoers.d/python"_file> "$@"

  5. Now open your pycharm and project you need to run/debugg the go to setting > project:projectname > Python Interpreter Click on Wheel Icon and Then click on "Add"

  6. In the new window that popup select Existing Environment > Select the shell script which you created python-sudo.sh. Then click OK > and then Click Apply

  7. Make sure that on top right side of editor near to green run button Run/Debug configuration small drop down menu for your file which you are about to execute/debug click on Edit Configuration and the same python interpreter is selected there as well which is python-sudo.sh.

  8. Now try executing/debugging, it should work.

Solution 4:[4]

Try to remove the shebang if you have it in your code and then try to run it......BTW this Worked for me.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user3684792
Solution 2 Antricks
Solution 3 Tomerikoo
Solution 4 Pranav Nagvekar