Unable to Link - Python not found?

Pretty certain I’m going to kick myself when I find out what I did wrong here but I am stumped and my Google-fu is not working.

When I try to compile, it will not link:

*** [.pio\build\d1_mini\firmware.elf] Implicit dependency `C:\Users\xxxxxxx\.platformio\platforms\espressif8266\builder\python' not found, needed by target `.pio\build\d1_mini\firmware.elf'.

Python 2.7 is in my %PATH% (this is Windows) and when I type “python” in the terminal it starts fine. When I look in C:\Users\xxxxx\.platformio\platforms\espressif8266\builder\ I see main.py but no “python” as it seems to be looking for.

This is a new install, new machine, so I clearly forgot something I did in the past. Any ideas?

How to reproduce it? Do you do just a simple building?

Yes sir. It does all the object files then I get the dreaded yellow text.

Does this happen on the most recent PlatformIO version? (open PIO terminal, pio upgrade --dev, get 4.0.4a1, restart vscode). Are there more system environment variables set regarding python?

The most recent release, yes. I installed 4.0.4a1 and restarted with the same issues.

PS C:\Users\Foo\OneDrive\Desktop\Xxxxxx\Git\xxxxxx> pio upgrade --dev 
Please wait while upgrading PlatformIO ...
PlatformIO has been successfully upgraded to 4.0.4a1
Release notes: https://docs.platformio.org/en/latest/history.html

Here’s my environment:

ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Foo\AppData\Roaming
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=Bar
ComSpec=C:\Windows\system32\cmd.exe
DriverData=C:\Windows\System32\Drivers\DriverData
GameFirst=C:\Program Files (x86)\ASUS\GameFirst\
HOMEDRIVE=C:
HOMEPATH=\Users\Foo
LOCALAPPDATA=C:\Users\Foo\AppData\Local
LOGONSERVER=\\Bar
NUMBER_OF_PROCESSORS=12
OneDrive=C:\Users\Foo\OneDrive
OneDriveConsumer=C:\Users\Foo\OneDrive
OS=Windows_NT
Path=C:\Users\Foo\.platformio\penv\Scripts;C:\Users\Foo\.platformio\penv;C:\Python27\;C:\Python27\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Git\cmd;C:\Program Files\PuTTY\;C:\Users\Foo\AppData\Local\Programs\Python\Python37\Scripts\;C:\Users\Foo\AppData\Local\Programs\Python\Python37\;C:\Users\Foo\AppData\Local\Microsoft\WindowsApps;;C:\Users\Foo\AppData\Local\Programs\Microsoft VS Code\bin;C:\Python27\;C:\Python27\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files
(x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Git\cmd;C:\Program Files\PuTTY\;C:\Users\Foo\AppData\Local\Programs\Python\Python37\Scripts\;C:\Users\Foo\AppData\Local\Programs\Python\Python37\;C:\Users\Foo\AppData\Local\Microsoft\WindowsApps;;C:\Users\Foo\AppData\Local\Programs\Microsoft VS Code\bin
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.CPL
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=9e0a
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\Users\Foo\OneDrive\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\Foo\AppData\Local\Temp
TMP=C:\Users\Foo\AppData\Local\Temp
USERDOMAIN=Bar
USERDOMAIN_ROAMINGPROFILE=Bar
USERNAME=Foo
USERPROFILE=C:\Users\Foo
windir=C:\Windows
PLATFORMIO_CALLER=vscode
TERM_PROGRAM=vscode
TERM_PROGRAM_VERSION=1.37.1
LANG=en_US.UTF-8
COLORTERM=truecolor

Quite odd.

Just for grins I uninstalled Python 3.x and 2.7, PlatformIO and VSCode. I reinstalled Python 2.7 (added it to path), then VSCode, then PlatformIO. Same issue.

It’s not a Python or PIO Core issue. Do you have antivirus tools in the system? They can block subprocesses.

I do, and generally it warns me when it does that.

I turned off AV and had another go - same issues. I had a look at my platformio.ini and remembered I have a couple of scripts called in there. I commented those out and things compile. This is perplexing because those scripts have been in my project a while. I call them with this line in the ini:

build_flags = python git_rev.py

And the script is fairly simple:

#!/usr/bin/python

import subprocess

# Get 0.0.0 version from latest Git tag
tagcmd = "git describe --tags --abbrev=0"
version = subprocess.check_output(tagcmd, shell=True).decode().strip()

# Get latest commit short from Git
revcmd = "git log --pretty=format:'%h' -n 1"
commit = subprocess.check_output(revcmd, shell=True).decode().strip()

# Get branch name from Git
branchcmd = "git rev-parse --abbrev-ref HEAD"
branch = subprocess.check_output(branchcmd, shell=True).decode().strip()

# Make all available for use in the macros
print("-DPIO_SRC_TAG={0}".format(version))
print("-DPIO_SRC_REV={0}".format(commit))
print("-DPIO_SRC_BRH={0}".format(branch))

As you point out it’s something I did, I’m just not sure what. :slight_smile:

What is your antivirus? Just to know for other users.

Bitdefender. And as long as we’re talking about it I find it highly performant, however it has a feature called “Safe Files” which is intended to protect against ransomware and the like which is highly annoying if you are developing. Like other products it tells you it blocked the process, and then you can whitelist it, but if you upgrade your tools it sees that as a different application so you go through it over again. I’d love to be able to exclude certain folders.

I did figure out my issue, not sure how I did it, and not sure why this is a “thing”:

If you look at the line from my ini I have build_flags = python git_rev.py but it should be build_flags = !python git_rev.py. So it was something I did somehow. :slight_smile:

What does the bang mean/do in this context?

1 Like

It means to pass whole line to system call. The same when you copy this line and paste into the terminal.

1 Like

Thanks Ivan, appreciate the answers.