Jump to content

Automated pip install esptool fails


Recommended Posts

I've been working for quite a while on an automated installer for python3.8.3 and Thonny3.2.7 and encountered a pretty strange problem - automated python install work perfectly. However using pip to install esptool returns error code 1. The strange thing is if i manually install it after running the python installer it does indeed install correctly (returns 0 instead).

The code i was using:

Local Const $sInstallerPath = @ScriptDir & "\python-3.8.3.exe"

Local $PythonResult = RunWait($sInstallerPath & " /quiet")

Local $ESPToolResult = RunWait(@ComSpec & " /c " & "pip install esptool")

MsgBox(0, "Installer returns", "Python result: " & $PythonResult & @CRLF & "esptool result: " & $ESPToolResult)

Than I thought that maybe python installer fires off multiple processes during installation and tried :

Local Const $sInstallerPath = @ScriptDir & "\python-3.8.3.exe"

Local $iPID = Run($sInstallerPath & " /quiet")
Local $PythonResult = ProcessWaitClose($iPID)

Local $ESPToolResult = RunWait(@ComSpec & " /c " & "pip install esptool")

MsgBox(0, "Installer returns", "Python result: " & $PythonResult & @CRLF & "esptool result: " & $ESPToolResult)

However, The problem still remains. some-why esptool install refuses to be automated with python but if i comment out the python install part it does work ?! (note that i comment it out after the script already installed python and did not manually install it myself).

Any idea why this happens ?

NOTE: I added the unattend.xml file im using but python.exe was too big - I'm using python3.8.3 for compatibility with thonny and the unattend files makes a minimal install just for thonny to work (target platform esp32 with micopython)

unattend.xml

Link to comment
Share on other sites

I did use RequireAdmin sorry for not adding it in the code above. Also if you look at the unattend.xml I added it does add python to path so there is no need to specify the path and I can simply call "pip install esptool" from cmd with no additional path so it does work.

Link to comment
Share on other sites

What I have found in the past is the script only recognizes environment variables that are available at the time of execution.  If you re-run the script it will recognize the updated environment variables.  I downloaded the latest Python-3.8.3.exe 32-bit and used the following which worked fine for me.

#RequireAdmin
Local $sInstallerPath = @ScriptDir & "\python-3.8.3.exe"
RunWait($sInstallerPath & " /quiet")
RunWait(@ComSpec & ' /c "C:\Program Files (x86)\Python38-32\Scripts\pip.exe" install esptool')

 

Link to comment
Share on other sites

I can't currently test it. However, its strange because the python installer should use "add to path" making it available on execution because esptool is installed later.

I will try your solution. The only problem is its not portable for all users as some may choose a different install directory which is why I wanted to make use of the "add to path" feature in the execution which should work as its done with the python installer making it available in cmd straight after with pip.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...