DEV Community

Cover image for PIP vs OneDrive: A Permission Battle!
Tahzib Mahmud Rifat
Tahzib Mahmud Rifat

Posted on

1

PIP vs OneDrive: A Permission Battle!

ERROR of python

When ever pip is used this warning is showed. The warnings indicate that pip is running into permission issues when trying to access or write to a folder (specifically, your OneDrive Documents folder). This can happen if some environment variables (like those for temporary files or SSL logging) are pointing to a location where you don’t have the necessary permissions.

Below are steps you can follow to fix the problem:

1. Check and Unset the SSLKEYLOGFILE Variable
Sometimes the SSLKEYLOGFILE environment variable is set (often for debugging SSL connections) and points to a protected folder. To check and clear it:

  1. Open Command Prompt and run: echo %SSLKEYLOGFILE%

If the output shows a path like C:\Users\88018\OneDrive\Documents\… , that’s likely causing the issue.

  1. Unset it for the current session by running: set SSLKEYLOGFILE=

Try installing your package again.

2. Redirect Your Temporary Directories
Pip uses temporary directories for caching and downloads. If these directories are set to a OneDrive folder, you may run into permission issues. You can change them as follows:

  1. Create a new temporary folder (if it doesn’t already exist):
    mkdir C:\Temp

  2. Set the TEMP and TMP environment variables to point to this folder:

    set TEMP=C:\Temp
    set TMP=C:\Temp
Enter fullscreen mode Exit fullscreen mode

3. Try Installing Packages Again
After unsetting SSLKEYLOGFILE and setting your temporary directory, try installing a package with pip. For example:

  1. pip install numpy --no-cache-dir --cache-dir C:\Temp or
  2. pip install flask --no-cache-dir --cache-dir C:\Temp

4. Run as Administrator (If Needed)
If you still see warnings or errors, try running the Command Prompt as an Administrator:

  • Press Win + S, type cmd, right-click Command Prompt, and select Run as administrator.
  • Then run your pip install command again.

In your PyCharm environment the variable still appears to be active. This is why when you run pip in PyCharm’s integrated terminal (which is using PowerShell), you still encounter the same permission errors.

There are a few ways to resolve this within PyCharm:

  1. Remove SSLKEYLOGFILE in the PyCharm Terminal Session Since you’re using PowerShell in PyCharm, you need to use PowerShell syntax to inspect and remove environment variables:

Check the variable in PowerShell:

In the PyCharm terminal, run:

powershell

echo $env:SSLKEYLOGFILE
This should display the value if it’s still set.

Remove the variable for the current session:

Run:
Remove-Item Env:SSLKEYLOGFILE
or you can also do:

powershell

$env:SSLKEYLOGFILE = ""
Verify that it’s gone:

Run again:

powershell

echo $env:SSLKEYLOGFILE
You should now get no output (or an empty line).

Now try installing numpy:

powershell

pip install numpy

  1. Set Up PyCharm’s Environment Variables Permanently If you’d like this change to apply every time you open a terminal or run a configuration from PyCharm, you can adjust your run/debug configurations or the default terminal settings:

Option A: Edit Run/Debug Configurations
In PyCharm, go to Run > Edit Configurations.
Select your project’s configuration (or create a new one).
In the Environment variables field, add:

  • Key: SSLKEYLOGFILE
  • Value: (leave it blank) Click OK to save. This ensures that whenever you run scripts or commands via PyCharm’s run configurations, the SSLKEYLOGFILE variable will be overridden to an empty value.

Option B: Modify PyCharm’s Terminal Settings
PyCharm’s integrated terminal inherits environment variables from your system. If your system still has the SSLKEYLOGFILE variable set, you might want to override it in PyCharm:

Go to File > Settings (or PyCharm > Preferences on macOS).
Navigate to Tools > Terminal.
In the Shell integration section, you can modify the Environment variables field. Add:

  • Key: SSLKEYLOGFILE
  • Value: (leave it blank) Apply and restart the PyCharm terminal.
  1. Verify and Install After removing or overriding the variable in PyCharm, verify by running in the PyCharm terminal:

powershell

echo $env:SSLKEYLOGFILE
You should see no output. Then try:

powershell

pip install numpy
If everything is set up correctly, pip should now connect without encountering the permission error.

GPT link: https://chatgpt.com/share/67a8e209-6e6c-8000-b5b3-3ad21f9ea979

Image description

Image description

Image description

Image description

Top comments (0)