Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'esptool' has no attribute '_main' at idf5.+ (VSC-958) #791

Closed
1 task done
Coloryr opened this issue Aug 26, 2022 · 15 comments
Closed
1 task done
Assignees
Labels
bug-report Bug Report from users on Github (don't use this tag manually, its supposed to be used via the issue) Issue Template Ignored Author hasn't follow the issue template

Comments

@Coloryr
Copy link

Coloryr commented Aug 26, 2022

OS

Windows

Operating System version

win11

Visual Studio Code version

1.70

ESP-IDF version

5.0

Python version

3.8.7

Doctor command output

47B5J1RSWB2H43WSZ38 KAO

Extension

No response

Description

in here

Debug Message

not

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.
@Coloryr Coloryr added the bug-report Bug Report from users on Github (don't use this tag manually, its supposed to be used via the issue) label Aug 26, 2022
@github-actions github-actions bot changed the title AttributeError: module 'esptool' has no attribute '_main' at idf5.+ AttributeError: module 'esptool' has no attribute '_main' at idf5.+ (VSC-958) Aug 26, 2022
@brianignacio5 brianignacio5 added the Issue Template Ignored Author hasn't follow the issue template label Aug 29, 2022
@brianignacio5
Copy link
Collaborator

This seems to be an issue with the virtual environment you are using. Try deleting the virtual environment and install it again.

@brianignacio5
Copy link
Collaborator

Closing this issue due to lack of response from user. Please comment here if you need further assistance.

@Jeff-Conley
Copy link

I am deleted the entire esp-tools folder and reinstalled it fresh which should have installed a new python environment. I am still getting the error message after reinstalling.

@brianignacio5
Copy link
Collaborator

Could you share the ESP-IDF: Doctor Command Output @Jeff-Conley ?

@Jeff-Conley
Copy link

---------------------------------------------- ESP-IDF Extension for Visual Studio Code report ---------------------------------------------
OS win32 x64 10.0.22000
System environment variable IDF_PYTHON_ENV_PATH
undefined
System environment variable PATH
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Microchip\xc8\v2.31\bin;C:\Program Files\Microchip\xc32\v4.00\bin;C:\Program Files\PuTTY;C:\Program Files\Microchip\xc8\v2.35\bin;C:\Program Files\Microchip\xc16\v2.00\bin;C:\Program Files (x86)\Atmel\Studio\7.0\atbackend;C:\Program Files\dotnet;C:\Program Files\Git\cmd;C:\Users\Jeffrey Conley\AppData\Local\Microsoft\WindowsApps;C:\Users\Jeffrey Conley\AppData\Local\Programs\Microsoft VS Code\bin
System environment variable PYTHON
undefined
Visual Studio Code version 1.71.1
Visual Studio Code language en
Visual Studio Code shell C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
ESP-IDF Extension version 1.5.0
Workspace folder c:\test_code\hello_world
---------------------------------------------------- Extension configuration settings ------------------------------------------------------
ESP-ADF Path (idf.espAdfPath) ${env:ADF_PATH}
ESP-IDF Path (idf.espIdfPath) c:\esp\esp-idf
ESP-MDF Path (idf.espMdfPath) c:\esp-idf-tools\esp-mdf
ESP-Matter Path (idf.espMatterPath) ${env:ESP_MATTER_PATH}
Custom extra paths (idf.customExtraPaths) c:\esp-tools\tools\xtensa-esp-elf-gdb\11.2_20220823\xtensa-esp-elf-gdb\bin;c:\esp-tools\tools\riscv32-esp-elf-gdb\11.2_20220823\riscv32-esp-elf-gdb\bin;c:\esp-tools\tools\xtensa-esp32-elf\esp-2022r1-11.2.0\xtensa-esp32-elf\bin;c:\esp-tools\tools\xtensa-esp32s2-elf\esp-2022r1-11.2.0\xtensa-esp32s2-elf\bin;c:\esp-tools\tools\xtensa-esp32s3-elf\esp-2022r1-11.2.0\xtensa-esp32s3-elf\bin;c:\esp-tools\tools\riscv32-esp-elf\esp-2022r1-11.2.0\riscv32-esp-elf\bin;c:\esp-tools\tools\esp32ulp-elf\2.28.51-esp-20191205\esp32ulp-elf-binutils\bin;c:\esp-tools\tools\esp32s2ulp-elf\2.28.51-esp-20191205\esp32s2ulp-elf-binutils\bin;c:\esp-tools\tools\cmake\3.23.1\bin;c:\esp-tools\tools\openocd-esp32\v0.11.0-esp32-20220706\openocd-esp32\bin;c:\esp-tools\tools\ninja\1.10.2;c:\esp-tools\tools\idf-exe\1.0.3;c:\esp-tools\tools\ccache\4.6.2\ccache-4.6.2-windows-x86_64;c:\esp-tools\tools\dfu-util\0.9\dfu-util-0.9-win64
Custom extra vars (idf.customExtraVars) {"OPENOCD_SCRIPTS":"c:\esp-tools\tools\openocd-esp32\v0.11.0-esp32-20220706/openocd-esp32/share/openocd/scripts","IDF_CCACHE_ENABLE":"1"}
Virtual env Python Path (idf.pythonBinPath) C:\esp-tools\python_env\idf5.0_py3.8_env\Scripts\python.exe
Serial port (idf.port) COM4
OpenOCD Configs (idf.openOcdConfigs) interface/ftdi/esp32_devkitj_v1.cfg,target/esp32s3.cfg
ESP-IDF Tools Path (idf.toolsPath) c:\esp-tools
Git Path (idf.gitPath) c:\esp-tools\tools\idf-git\2.30.1\cmd\git.exe
-------------------------------------------------------- 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 c:\esp-tools\tools\xtensa-esp-elf-gdb\11.2_20220823\xtensa-esp-elf-gdb\bin: true
Access to c:\esp-tools\tools\riscv32-esp-elf-gdb\11.2_20220823\riscv32-esp-elf-gdb\bin: true
Access to c:\esp-tools\tools\xtensa-esp32-elf\esp-2022r1-11.2.0\xtensa-esp32-elf\bin: true
Access to c:\esp-tools\tools\xtensa-esp32s2-elf\esp-2022r1-11.2.0\xtensa-esp32s2-elf\bin: true
Access to c:\esp-tools\tools\xtensa-esp32s3-elf\esp-2022r1-11.2.0\xtensa-esp32s3-elf\bin: true
Access to c:\esp-tools\tools\riscv32-esp-elf\esp-2022r1-11.2.0\riscv32-esp-elf\bin: true
Access to c:\esp-tools\tools\esp32ulp-elf\2.28.51-esp-20191205\esp32ulp-elf-binutils\bin: true
Access to c:\esp-tools\tools\esp32s2ulp-elf\2.28.51-esp-20191205\esp32s2ulp-elf-binutils\bin: true
Access to c:\esp-tools\tools\cmake\3.23.1\bin: true
Access to c:\esp-tools\tools\openocd-esp32\v0.11.0-esp32-20220706\openocd-esp32\bin: true
Access to c:\esp-tools\tools\ninja\1.10.2: true
Access to c:\esp-tools\tools\idf-exe\1.0.3: true
Access to c:\esp-tools\tools\ccache\4.6.2\ccache-4.6.2-windows-x86_64: true
Access to c:\esp-tools\tools\dfu-util\0.9\dfu-util-0.9-win64: true
Access to Virtual env Python Path (idf.pythonBinPath) true
Access to CMake in environment PATH undefined
Access to Ninja in environment PATH undefined
Access to ESP-IDF Tools Path (idf.toolsPath) true
-------------------------------------------------------- Configurations has spaces -------------------------------------------------------------
Spaces in system environment Path true
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 c:\esp-tools\tools\xtensa-esp-elf-gdb\11.2_20220823\xtensa-esp-elf-gdb\bin: false
Spaces in c:\esp-tools\tools\riscv32-esp-elf-gdb\11.2_20220823\riscv32-esp-elf-gdb\bin: false
Spaces in c:\esp-tools\tools\xtensa-esp32-elf\esp-2022r1-11.2.0\xtensa-esp32-elf\bin: false
Spaces in c:\esp-tools\tools\xtensa-esp32s2-elf\esp-2022r1-11.2.0\xtensa-esp32s2-elf\bin: false
Spaces in c:\esp-tools\tools\xtensa-esp32s3-elf\esp-2022r1-11.2.0\xtensa-esp32s3-elf\bin: false
Spaces in c:\esp-tools\tools\riscv32-esp-elf\esp-2022r1-11.2.0\riscv32-esp-elf\bin: false
Spaces in c:\esp-tools\tools\esp32ulp-elf\2.28.51-esp-20191205\esp32ulp-elf-binutils\bin: false
Spaces in c:\esp-tools\tools\esp32s2ulp-elf\2.28.51-esp-20191205\esp32s2ulp-elf-binutils\bin: false
Spaces in c:\esp-tools\tools\cmake\3.23.1\bin: false
Spaces in c:\esp-tools\tools\openocd-esp32\v0.11.0-esp32-20220706\openocd-esp32\bin: false
Spaces in c:\esp-tools\tools\ninja\1.10.2: false
Spaces in c:\esp-tools\tools\idf-exe\1.0.3: false
Spaces in c:\esp-tools\tools\ccache\4.6.2\ccache-4.6.2-windows-x86_64: false
Spaces in c:\esp-tools\tools\dfu-util\0.9\dfu-util-0.9-win64: false
Spaces in Virtual env Python Path (idf.pythonBinPath) false
Spaces in ESP-IDF Tools Path (idf.toolsPath) false
----------------------------------------------------------- Executables Versions -----------------------------------------------------------
Git version 2.30.1.windows.1
ESP-IDF version 5.0
Python version 3.8.7
Python's pip version 22.2.2
-------------------------------------------------- Python packages in idf.pythonBinPath ----------------------------------------------------
bitstring version: 3.1.9
certifi version: 2022.6.15.1
cffi version: 1.15.1
charset-normalizer version: 2.1.1
click version: 8.0.4
colorama version: 0.4.5
construct version: 2.10.68
contextlib2 version: 21.6.0
cryptography version: 36.0.2
ecdsa version: 0.18.0
esp-coredump version: 1.3
esptool version: 4.2.1
freertos-gdb version: 1.0.1
future version: 0.18.2
gcovr version: 5.2
idf-component-manager version: 1.1.4
idna version: 3.3
Jinja2 version: 3.0.3
kconfiglib version: 14.1.0
lxml version: 4.9.1
MarkupSafe version: 2.1.1
pip version: 22.2.2
psutil version: 5.9.2
pycparser version: 2.21
pyelftools version: 0.27
pygdbmi version: 0.9.0.2
Pygments version: 2.13.0
pyparsing version: 3.0.9
pyserial version: 3.5
pywin32 version: 304
PyYAML version: 6.0
reedsolo version: 1.5.4
requests version: 2.28.1
requests-toolbelt version: 0.9.1
schema version: 0.7.5
setuptools version: 65.3.0
six version: 1.16.0
tqdm version: 4.64.1
urllib3 version: 1.26.12
websocket-client version: 1.4.1
wheel version: 0.36.2
windows-curses version: 2.3.0
xmlrunner version: 1.7.7
---------------------------------------------------- Check ESP-IDF python requirements.txt -------------------------------------------------
Check ESP-IDF Python packages Python requirements are satisfied.
---------------------------------------------------- Check extension requirements.txt ------------------------------------------------------
Check Extension Python packages Python requirements are satisfied.
---------------------------------------------------- Check ESP-IDF debug adapter requirements.txt ------------------------------------------
Check Debug AdapterPython packages Python requirements are satisfied.
---------------------------------------------------- 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": "c:\esp-tools\tools\xtensa-esp32s3-elf\esp-2022r1-11.2.0\xtensa-esp32s3-elf\bin\xtensa-esp32s3-elf-gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"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
}


@Jeff-Conley
Copy link

I am able to compile with the compile button. I can also flash using the terminal command idf.py flash . I installed it using the same steps I used on a co-workers computer and was able to flash using that. I am guessing there is some config file that I messed up accidently somewhere that I am not deleting when I tried uninstalling and re-installing. The only thing that I can think of that may have messed it up is update pip at one point. I have also uninstalled python on my system trying to fix the problem. which didn't seem to work.

@kurau1
Copy link

kurau1 commented Sep 26, 2022

Hello, @Jeff-Conley
Do you solve the problem?
i am facing the same issue. i reinstall windows, reinstall VScode, it didn't work.
i wanna use idf5! it can bulid project successfully but can't flash device. and give this information in terminal.

Traceback (most recent call last):
  File "f:\ESP32\idf\esp-idf\components\esptool_py\esptool\esptool.py", line 22, in <module>
    esptool._main()  # type: ignore
AttributeError: module 'esptool' has no attribute '_main'

i have reinstall windows and vscode so many times. i install esp-idf v4.4 in VScode, it worked, can build and flash. but when i install esp-idf v5. i can't flash! it's a torture.

i reinstall window , then download VScode and ESP extension. download ESP-IDF V4.4.2 and ESP-TOOL. it worked.
i reinstall window , then download VScode and ESP extension. download ESP-IDF V5 and ESP-TOOL. it didn't work.
i just think this is a bug in ESP-IDF V5. i used the same method to download ESP-IDF and ESP-TOOL, V4.4.2 can work. but V5.

@brianignacio5
Copy link
Collaborator

This seems to be happening in ESP-IDF itself as shown in here. Could you delete the esptool_py directory pulling the sub component again and your espressif's python_env virtual env to reinstall faulty python packages.

@xiaolongba
Copy link
Contributor

Hello @brianignacio5

I also ran into this issue and followed your tips above, but the issue is still present

Could you delete the esptool_py directory pulling the sub component again and your espressif's python_env virtual env to reinstall faulty python packages

it seems that the workaround mentioned is not valid. could you give me a hand?
report.txt

@Jeff-Conley
Copy link

So it isn't a great workaround but I got it working by creating a new windows user on my computer named "build" and installed it fresh using that. Seems to be working again on that account but still not working on my main account.

@xiaolongba
Copy link
Contributor

So it isn't a great workaround but I got it working by creating a new windows user on my computer named "build" and installed it fresh using that. Seems to be working again on that account but still not working on my main account.

it is magic😂

@xiaolongba
Copy link
Contributor

xiaolongba commented Nov 3, 2022

@brianignacio5

Hello Bro, any updates about it? the issue is still present. the guy from ESP-IDF told me that the root is caused by the vscode-extension, while as you mentioned above, it seems to be related with ESP-IDF😂

any other workarounds can share with me? thanks in advance.

pls, let me know if a new ticket is needed.

@brianignacio5
Copy link
Collaborator

brianignacio5 commented Nov 3, 2022

Hey @xiaolongba I was busy with other tasks but today I'll try to find the reason why is it failing in the extension xD. Not sure what is making it break from extension.

@xiaolongba
Copy link
Contributor

Hey @xiaolongba I was busy with other tasks but today I'll try to find the reason why is it failing in the extension xD. Not sure what is making it break from extension.

perfect. many thanks for your prompt replies

@xiaolongba
Copy link
Contributor

@brianignacio5
Hello Bro,

it seems that there is one guy who gave us one workaround I have a try just now and it works. the details as this link:espressif/esp-idf#9861 (comment)

espressif-bot pushed a commit to espressif/esp-idf that referenced this issue Nov 22, 2022
Importing esptool in wrappers could cause importing the wrapper itself.
Updating the PATH is not reliable. For example, os.path.realpath()
changes the Windows driver letter to uppercase therefore, misses the
right path for users with small device letters in their PATH. Removing
paths without considering cases could also lead to errors.

This fix invokes esptool scripts as modules without the need to
importing them.

Closes #9861

Closes espressif/vscode-esp-idf-extension#791
espressif-bot pushed a commit to espressif/esp-idf that referenced this issue Nov 24, 2022
Importing esptool in wrappers could cause importing the wrapper itself.
Updating the PATH is not reliable. For example, os.path.realpath()
changes the Windows driver letter to uppercase therefore, misses the
right path for users with small device letters in their PATH. Removing
paths without considering cases could also lead to errors.

This fix invokes esptool scripts as modules without the need to
importing them.

Closes #9861

Closes espressif/vscode-esp-idf-extension#791
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-report Bug Report from users on Github (don't use this tag manually, its supposed to be used via the issue) Issue Template Ignored Author hasn't follow the issue template
Projects
None yet
Development

No branches or pull requests

5 participants