Setting PYTHONNOUSERSITE, was not set

User avatar
stevenbennett
Posts: 34
Joined: Sun May 19, 2024 7:30 am
Location: High Bentham, UK

Setting PYTHONNOUSERSITE, was not set

Postby stevenbennett » Sun May 19, 2024 7:42 am

When I run the ESP-IDF 5.2 PowerShell shortcut it all works but there is a warning message "Setting PYTHONNOUSERSITE, was not set". Is it important and how can I fix whatever is causing the message?
Thanks
Steve

ESP_Jakub
Posts: 4
Joined: Tue Oct 10, 2023 11:48 am

Re: Setting PYTHONNOUSERSITE, was not set

Postby ESP_Jakub » Mon May 20, 2024 8:14 am

Hello Steve,

PYTHONNOUSERSITE is defined here: https://python.readthedocs.io/en/v2.7.2 ... NOUSERSITE

From PEP 370 definition:
user site directory
A site directory inside the users’ home directory. A user site directory is specific to a Python version. The path contains the version number (major and minor only).
Windows
%APPDATA%/Python/Python26/site-packages
When you run ESP-IDF 5.2 PowerShell shortcut the check for PYTHONNOUSERSITE value is performed. If it is not set the variable is set automatically. It is handled by these few lines which are run everytime you run ESP-IDF 5.2 PowerShell shortcut:

Code: Select all

# Set PYTHONNOUSERSITE to avoid loading of Python packages from AppData\Roaming profile
if ($null -eq $env:PYTHONNOUSERSITE) {
    "Setting PYTHONNOUSERSITE, was not set"
    $env:PYTHONNOUSERSITE="True"
}
So basically you donť have to do anything if everything works for you.

But it looks like the IDF environment was probably not installed correctly, so if you want to get rid of the text I suppose reinstallation of the framework should work.

Because you mentioned the ESP-IDF 5.2 PowerShell shortcut, I believe you have used the IDF Installer, so you can stay with this option and install the framework into the already installed ESP-IDF directory and later delete the original one. (maybe there could be a newer version of the installer https://dl.espressif.com/dl/esp-idf/)

I hope this helps you to understand the PYTHONNOUSERSITE and as said above if everything works, basically you do not have to do anything about the warning.


Regards,
Jakub

User avatar
stevenbennett
Posts: 34
Joined: Sun May 19, 2024 7:30 am
Location: High Bentham, UK

Re: Setting PYTHONNOUSERSITE, was not set

Postby stevenbennett » Fri May 24, 2024 12:36 pm

Thank you for the comments Jakub; I pleased that all should be OK despite the warning message. I seem to have Python in the following locations:
e:\ESP_tool>where python
C:\Program Files\Python312\python.exe
C:\Users\Steven\.espressif\python_env\idf5.2_py3.12_env\Scripts\python.exe
C:\Users\Steven\AppData\Local\Microsoft\WindowsApps\python.exe
If I wanted to Set PYTHONNOUSERSITE permanently is there a way to do this? I don't understand the concept of a Python HOME, or any other, directory (folder I assume?), so that's where I'm starting from.

ESP_Jakub
Posts: 4
Joined: Tue Oct 10, 2023 11:48 am

Re: Setting PYTHONNOUSERSITE, was not set

Postby ESP_Jakub » Mon May 27, 2024 9:47 am

Hello Steven,

When using ESP-IDF installed by IDF Installer, there is a bundled Python included, to not mess up your environment.

This Python is used in the created environment every time when running the ESP-IDF shortcut.
That is why the warning is there every time because the variable is set in this created environment.

If you add the PYTHONNOUSERSITE variable to your System environment variables with the value corresponding to "True" it should solve it.
But maybe there is a reason why you don't have the variable set to the value because of some other use cases so that is why you don't need to do anything to not mess up your environment and let the variable be set only in a newly created environment in the scope os ESP-IDF shortcut.


Hope this helps.
Best regards,
Jakub

User avatar
stevenbennett
Posts: 34
Joined: Sun May 19, 2024 7:30 am
Location: High Bentham, UK

Re: Setting PYTHONNOUSERSITE, was not set

Postby stevenbennett » Mon May 27, 2024 10:12 am

Yes I see your point Jakub, I will take your advice and just leave it. I'm afraid I am one of those people that don't like to see any messages that suggest something could be fixed!
Thank you for your help
Steve

Who is online

Users browsing this forum: No registered users and 73 guests