espressif / vscode-esp-idf-extension

Visual Studio Code extension for ESP-IDF projects
Apache License 2.0
1.06k stars 305 forks source link

Ubuntu 23.04 has adopted PEP 668 and this is preventing the extension from configuring (VSC-1098) #949

Closed moefear85 closed 1 year ago

moefear85 commented 1 year ago

OS

Linux

Operating System version

Ubuntu 23.04

Visual Studio Code version

1.77.3

ESP-IDF version

master

Python version

3.11.2

Doctor command output

---------------------------------------------- ESP-IDF Extension for Visual Studio Code report --------------------------------------------- OS linux x64 6.2.0-20-generic System environment variable IDF_PYTHON_ENV_PATH undefined System environment variable PATH

/.local/bin:/software/miniconda/bin:/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/software/espressif/tools/xtensa-lx106-elf/bin:/scripts:/media/moefear/BACKUP/scripts:/software/espressif/tools/xtensa-lx106-elf/bin:/scripts:/media/moefear/BACKUP/scripts System environment variable PYTHON undefined Visual Studio Code version 1.77.3 Visual Studio Code language en Visual Studio Code shell /usr/bin/bash ESP-IDF Extension version 1.6.1 Workspace folder /tmp/t1 ---------------------------------------------------- Extension configuration settings ------------------------------------------------------ ESP-ADF Path (idf.espAdfPath) /source/esp-adf ESP-IDF Path (idf.espIdfPath) /source/esp-idf ESP-MDF Path (idf.espMdfPath) ${env:MDF_PATH} ESP-Matter Path (idf.espMatterPath) ${env:ESP_MATTER_PATH} Custom extra paths (idf.customExtraPaths) /software/espressif/tools/xtensa-esp-elf-gdb/12.1_20221002/xtensa-esp-elf-gdb/bin:/software/espressif/tools/riscv32-esp-elf-gdb/12.1_20221002/riscv32-esp-elf-gdb/bin:/software/espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin:/software/espressif/tools/xtensa-esp32s2-elf/esp-12.2.0_20230208/xtensa-esp32s2-elf/bin:/software/espressif/tools/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-esp32s3-elf/bin:/software/espressif/tools/riscv32-esp-elf/esp-12.2.0_20230208/riscv32-esp-elf/bin:/software/espressif/tools/esp32ulp-elf/2.35_20220830/esp32ulp-elf/bin:/software/espressif/tools/openocd-esp32/v0.12.0-esp32-20230313/openocd-esp32/bin:/software/espressif/tools/esp-rom-elfs/20230320 Custom extra vars (idf.customExtraVars) OPENOCD_SCRIPTS: /software/espressif/tools/openocd-esp32/v0.12.0-esp32-20230313/openocd-esp32/share/openocd/scripts ESP_ROM_ELF_DIR: /software/espressif/tools/esp-rom-elfs/20230320/ Virtual env Python Path (idf.pythonBinPath) python Serial port (idf.port) /dev/ttyUSB1 OpenOCD Configs (idf.openOcdConfigs) board/esp32-wrover-kit-3.3v.cfg ESP-IDF Tools Path (idf.toolsPath) /software/espressif Git Path (idf.gitPath) git -------------------------------------------------------- Configurations access ------------------------------------------------------------- Access to ESP-ADF Path (idf.espAdfPath) false Access to ESP-IDF Path (idf.espIdfPath) true Access to ESP-MDF Path (idf.espMdfPath) false Access to ESP-Matter Path (idf.espMatterPath) false Access to ESP-IDF Custom extra paths Access to /software/espressif/tools/xtensa-esp-elf-gdb/12.1_20221002/xtensa-esp-elf-gdb/bin: true Access to /software/espressif/tools/riscv32-esp-elf-gdb/12.1_20221002/riscv32-esp-elf-gdb/bin: true Access to /software/espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin: true Access to /software/espressif/tools/xtensa-esp32s2-elf/esp-12.2.0_20230208/xtensa-esp32s2-elf/bin: true Access to /software/espressif/tools/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-esp32s3-elf/bin: true Access to /software/espressif/tools/riscv32-esp-elf/esp-12.2.0_20230208/riscv32-esp-elf/bin: true Access to /software/espressif/tools/esp32ulp-elf/2.35_20220830/esp32ulp-elf/bin: true Access to /software/espressif/tools/openocd-esp32/v0.12.0-esp32-20230313/openocd-esp32/bin: true Access to /software/espressif/tools/esp-rom-elfs/20230320: true Access to Virtual env Python Path (idf.pythonBinPath) false Access to CMake in environment PATH true Access to Ninja in environment PATH true Access to ESP-IDF Tools Path (idf.toolsPath) true -------------------------------------------------------- Configurations has spaces ------------------------------------------------------------- Spaces in system environment Path false Spaces in ESP-ADF Path (idf.espAdfPath) false Spaces in ESP-IDF Path (idf.espIdfPath) false Spaces in ESP-MDF Path (idf.espMdfPath) false Spaces in ESP-Matter Path (idf.espMatterPath) false Spaces in ESP-IDF Custom extra paths Spaces in /software/espressif/tools/xtensa-esp-elf-gdb/12.1_20221002/xtensa-esp-elf-gdb/bin: false Spaces in /software/espressif/tools/riscv32-esp-elf-gdb/12.1_20221002/riscv32-esp-elf-gdb/bin: false Spaces in /software/espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin: false Spaces in /software/espressif/tools/xtensa-esp32s2-elf/esp-12.2.0_20230208/xtensa-esp32s2-elf/bin: false Spaces in /software/espressif/tools/xtensa-esp32s3-elf/esp-12.2.0_20230208/xtensa-esp32s3-elf/bin: false Spaces in /software/espressif/tools/riscv32-esp-elf/esp-12.2.0_20230208/riscv32-esp-elf/bin: false Spaces in /software/espressif/tools/esp32ulp-elf/2.35_20220830/esp32ulp-elf/bin: false Spaces in /software/espressif/tools/openocd-esp32/v0.12.0-esp32-20230313/openocd-esp32/bin: false Spaces in /software/espressif/tools/esp-rom-elfs/20230320: false Spaces in Virtual env Python Path (idf.pythonBinPath) false Spaces in ESP-IDF Tools Path (idf.toolsPath) false ----------------------------------------------------------- Executables Versions ----------------------------------------------------------- Git version 2.39.2 ESP-IDF version 5.1.0 Python version 3.11.2 Python's pip version 23.0.1 -------------------------------------------------- Project configuration settings ---------------------------------------------------------- -------------------------------------------------- Python packages in idf.pythonBinPath ---------------------------------------------------- apt-xapian-index version: 0.49 bitstring version: 3.1.7 blinker version: 1.5 Brlapi version: 0.8.4 Brotli version: 1.0.9 certifi version: 2022.9.24 chardet version: 5.1.0 click version: 8.1.3 colorama version: 0.4.6 command-not-found version: 0.3 cryptography version: 38.0.4 cupshelpers version: 1.0 dbus-python version: 1.3.2 defer version: 1.0.6 distlib version: 0.3.6 distro version: 1.8.0 distro-info version: 1.5 filelock version: 3.9.0 fuse-python version: 1.0.5 gpg version: 1.18.0 guizero version: 1.3.0 httplib2 version: 0.20.4 idna version: 3.3 importlib-metadata version: 4.12.0 jaraco.classes version: 3.2.1 jeepney version: 0.8.0 keyring version: 23.9.3 language-selector version: 0.1 launchpadlib version: 1.11.0 lazr.restfulclient version: 0.14.5 lazr.uri version: 1.0.6 louis version: 3.24.0 markdown-it-py version: 2.1.0 mdurl version: 0.1.2 more-itertools version: 8.10.0 mutagen version: 1.46.0 netifaces version: 0.11.0 numpy version: 1.24.2 oauthlib version: 3.2.2 olefile version: 0.46 pexpect version: 4.8.0 Pillow version: 9.4.0 pip version: 23.0.1 platformdirs version: 3.0.0 ptyprocess version: 0.7.0 pycairo version: 1.20.1 pycryptodomex version: 3.11.0 pycups version: 2.0.1 Pygments version: 2.14.0 PyGObject version: 3.44.1 PyJWT version: 2.6.0 pylibacl version: 0.6.0 pyparsing version: 3.0.9 PyQt5 version: 5.15.9 PyQt5-sip version: 12.11.1 python-apt version: 2.5.3+ubuntu1 python-dateutil version: 2.8.2 python-debian version: 0.1.49+ubuntu2 pyxattr version: 0.8.0 pyxdg version: 0.28 PyYAML version: 6.0 reportlab version: 3.6.12 requests version: 2.28.1 rich version: 13.3.1 SecretStorage version: 3.3.3 setuptools version: 66.1.1 six version: 1.16.0 systemd-python version: 235 tornado version: 6.2 ubuntu-advantage-tools version: 8001 ubuntu-drivers-common version: 0.0.0 ufw version: 0.36.1 unattended-upgrades version: 0.1 urllib3 version: 1.26.12 usb-creator version: 0.3.16 virtualenv version: 20.19.0+ds wadllib version: 1.3.6 websockets version: 10.4 wheel version: 0.38.4 wxPython version: 4.2.0 xdg version: 5 xkit version: 0.0.0 yt-dlp version: 2023.3.4 zipp version: 1.0.0 ---------------------------------------------------- Check ESP-IDF python requirements.txt ------------------------------------------------- Check ESP-IDF Python packages Error ---------------------------------------------------- Check extension requirements.txt ------------------------------------------------------ Check Extension Python packages Error ---------------------------------------------------- Check ESP-IDF debug adapter requirements.txt ------------------------------------------ Check Debug AdapterPython packages Error ---------------------------------------------------- Visual Studio Code launch.json -------------------------------------------------------- { "version": "0.2.0", "configurations": [ { "type": "espidf", "name": "Launch", "request": "launch" } ] } ---------------------------------------------------- Visual Studio Code c_cpp_properties.json ---------------------------------------------- { "configurations": [ { "name": "ESP-IDF", "compilerPath": "/software/espressif/tools/xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc", "includePath": [ "${config:idf.espIdfPath}/components/**", "${config:idf.espIdfPathWin}/components/**", "${config:idf.espAdfPath}/components/**", "${config:idf.espAdfPathWin}/components/**", "${workspaceFolder}/**" ], "browse": { "path": [ "${config:idf.espIdfPath}/components", "${config:idf.espIdfPathWin}/components", "${config:idf.espAdfPath}/components/**", "${config:idf.espAdfPathWin}/components/**", "${workspaceFolder}" ], "limitSymbolsToIncludedHeaders": false } } ], "version": 4 } ----------------------------------------------------------- Latest error ----------------------------------------------------------------- Latest error at Unknown error in ESP-IDF doctor command -------------------------------------------------------------------------------------------------------------------------------------------- ### Extension _No response_ ### Description As the title mentions. ### Debug Message ```plain error: externally-managed-environment × This environment is externally managed ╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install. If you wish to install a non-Debian-packaged Python package, create a virtual environment using python3 -m venv path/to/venv. Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make sure you have python3-full installed. If you wish to install a non-Debian packaged Python application, it may be easiest to use pipx install xyz, which will manage a virtual environment for you. Make sure you have pipx installed. See /usr/share/doc/python3.11/README.venv for more information. note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. hint: See PEP 668 for the detailed specification. Command failed: "/usr/bin/python" -m pip install --user virtualenv error: externally-managed-environment × This environment is externally managed ╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install. If you wish to install a non-Debian-packaged Python package, create a virtual environment using python3 -m venv path/to/venv. Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make sure you have python3-full installed. If you wish to install a non-Debian packaged Python application, it may be easiest to use pipx install xyz, which will manage a virtual environment for you. Make sure you have pipx installed. See /usr/share/doc/python3.11/README.venv for more information. ``` ### Other Steps to Reproduce I tried using a python virtual environment, including the one install.sh creates, but the extension detects this, and for some reason, complains and doesn't accept it. I feel this is an unnecessary constraint. ### I have checked existing issues, online documentation and the Troubleshooting Guide - [X] I confirm I have checked existing issues, online documentation and Troubleshooting guide.
moefear85 commented 1 year ago

note that virtualenv is already installed on my system.

mickeyl commented 1 year ago

This has little to do with ESP-IDF or this extension (although it's ­– among hundreds of other packages ­also ­– affected). Please also refer to https://github.com/pypa/pip/issues/11776 and https://discuss.python.org/t/pep-668-marking-python-base-environments-as-externally-managed/10302 where workarounds / solutions are discussed. I'm not sure whether this extension can do anything to work around it.

moefear85 commented 1 year ago

here's the beef: the extension insists on the system-wide python when its unnecessary, which would have avoided the problem. the guys at ubuntu atleast know what their talking about, and any script that needs to install packages should allow the specification of an arbitary venv for that

brianignacio5 commented 1 year ago

Added the fix in this vsix installer

ankit-thealchemist commented 1 year ago

I am still facing the error after installing the above vsix installer. idf_versions.txt has (1) KB idf_versions.txt progress: 100.00% (0.08 / 0.08) KB /bin/sh: 1: /home/ankit/.espressif/python_env/idf4.4_py3.11_env/: Permission denied Command failed: "/home/ankit/.espressif/python_env/idf4.4_py3.11_env/" "/media/ankit/Win_D/IOTCode/framework/esp-idf/tools/check_python_dependencies.py" -r "/media/ankit/Win_D/IOTCode/framework/esp-idf/tools/requirements/requirements.core.txt" /bin/sh: 1: /home/ankit/.espressif/python_env/idf4.4_py3.11_env/: Permission denied Installing ESP-IDF extension python packages in undefined ...

/bin/sh: 1: undefined: not found Command failed: "undefined" -m pip install --upgrade --constraint "/home/ankit/.vscode/extensions/espressif.esp-idf-extension-1.6.1/espidf.constraints.txt" --no-warn-script-location -r "/home/ankit/.vscode/extensions/espressif.esp-idf-extension-1.6.1/requirements.txt" /bin/sh: 1: undefined: not found idf_versions.txt has (1) KB idf_versions.txt progress: 100.00% (0.08 / 0.08) KB /bin/sh: 1: /home/ankit/.espressif/python_env/idf4.4_py3.11_env/: Permission denied Command failed: "/home/ankit/.espressif/python_env/idf4.4_py3.11_env/" "/media/ankit/Win_D/IOTCode/framework/esp-idf/tools/check_python_dependencies.py" -r "/media/ankit/Win_D/IOTCode/framework/esp-idf/tools/requirements/requirements.core.txt" /bin/sh: 1: /home/ankit/.espressif/python_env/idf4.4_py3.11_env/: Permission denied

brianignacio5 commented 1 year ago

You can see the issue is that your user has no permission to write in folder /home/ankit/.espressif/python_env/idf4.4_py3.11_env/

ankit-thealchemist commented 1 year ago

You can see the issue is that your user has no permission to write in folder /home/ankit/.espressif/python_env/idf4.4_py3.11_env/

could you let me know how to enable it!

brianignacio5 commented 1 year ago

In a terminal write sudo chmod 777 /home/ankit/.espressif/python_env/idf4.4_py3.11_env

ankit-thealchemist commented 1 year ago

problem solved by putting the idf python(python virtual environment) in the settings. image