platformio-core-installer icon indicating copy to clipboard operation
platformio-core-installer copied to clipboard

Can not find Python Interpreter

Open ZengShifeng opened this issue 3 years ago • 91 comments

Solution

If you use PlatformIO IDE, please ensure that platformio-ide.useBuiltinPython option is enabled (set to true).

Windows and macOS

PlatformIO IDE comes with built-in portable Python 3 for Windows and macOS. YOU DO NOT NEED to install Python interpreter manually. If you use PlatformIO IDE and experience this issue, please navigate to %HOME%/.platformio/python3 folder and check that python.exe (Windows) or bin/python works on your machine. In case if they don't work, please install manually the latest Python 3 using this guide. Restart PlatformIO IDE (VScode).

Linux

Please install the following package and restart IDE:

sudo apt-get install python3-venv

If you use a custom Python version, then

sudo apt-get install python3.xx-venv

where python3.xx equals the version of your Python interpreter (check it via python3 --version). For example, python3.10-venv for Python 3.10.

Now, please check your Python installation:

python3 -c "import venv; import ensurepip; print('Congrats! Python `venv` is already installed!')"

I still experience this issue

If you still experience this issue, please leave a comment below and describe your configuration (operating system, its version, etc.). We would be glad to help you.

Regards, Your friends at PlatformIO.


%23 Configuration

VSCode: 1.61.2 PIO IDE: v2.3.4 System: Windows_NT, 10.0.19043, x64

%23 Exception

Error: Can not find Python Interpreter. Please install Python 3.6 or above manually
	at H.value (c:\Users\Administrator\.vscode\extensions\platformio.platformio-ide-2.3.4\node_modules\platformio-node-helpers\dist\index.js:1:765899)
	at runMicrotasks (<anonymous>)
	at processTicksAndRejections (internal/process/task_queues.js:93:5)
	at async H.value (c:\Users\Administrator\.vscode\extensions\platformio.platformio-ide-2.3.4\node_modules\platformio-node-helpers\dist\index.js:1:764349)
	at async t.default.install (c:\Users\Administrator\.vscode\extensions\platformio.platformio-ide-2.3.4\dist\extension.js:1:6773)
	at async c:\Users\Administrator\.vscode\extensions\platformio.platformio-ide-2.3.4\dist\extension.js:1:12776

ZengShifeng avatar Oct 21 '21 05:10 ZengShifeng

Could you run platformio.exe from c:\Users\Administrator\.platformio\python3? Does it work?

ivankravets avatar Oct 21 '21 11:10 ivankravets

Thank you Platformio seems to be installed OK

SaturdayScience avatar Nov 04 '21 19:11 SaturdayScience

I still can't install

image

image

I'm on Debian 11.1

I'v uninstall vscode, remove ~/.vscode and ~/platformio, reboot machine, but nothing works

scorninpc avatar Nov 07 '21 20:11 scorninpc

I found the problem. The recipe of AppImage has a problem, not VSCode. Installing de .deb all works

scorninpc avatar Nov 07 '21 20:11 scorninpc

I am on macOS Version 12.0.1 (21A559). The folder %HOME%/.platformio/python3/bin contains python3 but not python. Running python3 correctly starts up Python 3.8.9 (default, Jul 19 2021, 09:37:32) but since there is no python command I assume that 2.7 (the system default) is loaded. How do I correct this?

swanlm avatar Jan 09 '22 13:01 swanlm

@swanlm we don't use %HOME%/.platformio/python3 directly. We use it to create Python virtual environment that is located in %HOME%/.platformio/penv and contains python.

Do you see any errors if try to install PlatformIO Core manually https://docs.platformio.org/en/latest/core/installation.html#super-quick-mac-linux ?

ivankravets avatar Jan 09 '22 13:01 ivankravets

@ivankravets thanks for the quick response. I get no errors when installing PlatformIO Core manually. But as soon as I open vscode it wants to install PlatformIO IDE. At that point I get "PlatformIO: Can not find working Python 3.6+ Interpreter." Aborting installation gives me: Error: Can not find Python Interpreter. Please install Python 3.6 or above manually at a.value (/Users/lanceswan/.vscode/extensions/platformio.platformio-ide-2.4.0/node_modules/platformio-node-helpers/dist/index.js:1:778120) at processTicksAndRejections (internal/process/task_queues.js:93:5) at async a.value (/Users/lanceswan/.vscode/extensions/platformio.platformio-ide-2.4.0/node_modules/platformio-node-helpers/dist/index.js:1:780890) at async S.install (/Users/lanceswan/.vscode/extensions/platformio.platformio-ide-2.4.0/dist/extension.js:1:4373) at async /Users/lanceswan/.vscode/extensions/platformio.platformio-ide-2.4.0/dist/extension.js:1:28136...

swanlm avatar Jan 09 '22 13:01 swanlm

Could you remove %HOME%/.platformio/python3 and %HOME%/.platformio/penv folders and restart VSCode?

ivankravets avatar Jan 09 '22 13:01 ivankravets

I get the same error. I am using vscode in conjunction with Fusion 360 and wonder if this related? I saw this in the console output.

console.ts:137 [Extension Host] /usr/bin/python3 Error: Python path configuration: PYTHONHOME = '/Users/lanceswan/Library/Application Support/Autodesk/webdeploy/production/88ce6bc1c34decd89efb26d037ca39bd2adac037/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current' PYTHONPATH = '/Users/lanceswan/Library/Application Support/Autodesk/webdeploy/production/88ce6bc1c34decd89efb26d037ca39bd2adac037/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/site-packages' program name = '/Library/Developer/CommandLineTools/usr/bin/python3' isolated = 0 environment = 1 user site = 1 import site = 1 sys._base_executable = '/Library/Developer/CommandLineTools/usr/bin/python3' sys.base_prefix = '/Users/lanceswan/Library/Application Support/Autodesk/webdeploy/production/88ce6bc1c34decd89efb26d037ca39bd2adac037/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current' sys.base_exec_prefix = '/Users/lanceswan/Library/Application Support/Autodesk/webdeploy/production/88ce6bc1c34decd89efb26d037ca39bd2adac037/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current' sys.executable = '/Library/Developer/CommandLineTools/usr/bin/python3' sys.prefix = '/Users/lanceswan/Library/Application Support/Autodesk/webdeploy/production/88ce6bc1c34decd89efb26d037ca39bd2adac037/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current' sys.exec_prefix = '/Users/lanceswan/Library/Application Support/Autodesk/webdeploy/production/88ce6bc1c34decd89efb26d037ca39bd2adac037/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current' sys.path = [ '/Users/lanceswan/Library/Application Support/Autodesk/webdeploy/production/88ce6bc1c34decd89efb26d037ca39bd2adac037/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/site-packages', '/Users/lanceswan/Library/Application Support/Autodesk/webdeploy/production/88ce6bc1c34decd89efb26d037ca39bd2adac037/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python38.zip', '/Users/lanceswan/Library/Application Support/Autodesk/webdeploy/production/88ce6bc1c34decd89efb26d037ca39bd2adac037/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.8', '/Users/lanceswan/Library/Application Support/Autodesk/webdeploy/production/88ce6bc1c34decd89efb26d037ca39bd2adac037/Autodesk Fusion 360.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.8/lib-dynload', ] Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding Python runtime state: core initialized ModuleNotFoundError: No module named 'encodings'

Current thread 0x0000000109ad2600 (most recent call first): <no Python frame>

at /Users/lanceswan/.vscode/extensions/platformio.platformio-ide-2.4.0/node_modules/platformio-node-helpers/dist/index.js:1:5240
at ChildProcess.r (/Users/lanceswan/.vscode/extensions/platformio.platformio-ide-2.4.0/node_modules/platformio-node-helpers/dist/index.js:1:5134)
at ChildProcess.emit (events.js:315:20)
at ChildProcess.EventEmitter.emit (domain.js:467:12)
at maybeClose (internal/child_process.js:1048:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)

swanlm avatar Jan 09 '22 14:01 swanlm

Sorry, we can't provide more help. It seems that Autodesk totally broke your system. They overwrote the system Python with something own broken. You can try to remove them from your PATH in init shell script.

ivankravets avatar Jan 09 '22 14:01 ivankravets

Thanks; how would I do that, if you don't mind me asking?

swanlm avatar Jan 09 '22 14:01 swanlm

Please forward your question to https://community.platformio.org/ to keep this issue clean. Thanks for undersatding.

ivankravets avatar Jan 09 '22 14:01 ivankravets

No problem and thanks for your help!

swanlm avatar Jan 09 '22 14:01 swanlm

Hi, this resolved my problem: https://community.platformio.org/t/restricting-platformio-installation/12402

Specifically setting "Platformio-ide: Activate Only On Platform IOProject" to true.

swanlm avatar Jan 09 '22 14:01 swanlm

Ah... this is a custom Autodesk extension that breaks the whole process.env :(

ivankravets avatar Jan 09 '22 14:01 ivankravets

hi, I just tried to run python get-platformio.py and it provided some error, I dont know why. But issue I have now is absolutelly F* CRAZY message "No pyvenv.cfg file" all the time yet after uninstalling and reainstalling python 310, into c:\ root or into user folder (win10) ... I simply CANT RUN any f* python now .... please, can you help me?

well, now I tried to use absolute path to reinstalled python and got this....

x:\~web\220131\platformio-cli-core-setup>c:\python310\python get-platformio.py
Installer version: 1.1.0
Platform: Windows-10
Python version: 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)]
Python path: c:\python310\python.exe
Creating a virtual environment at C:\Users\petra\.platformio\penv
Updating Python package manager (PIP) in a virtual environment
Virtual environment has been successfully created!
Installing PlatformIO Core
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /simple/platformio/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /simple/platformio/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /simple/platformio/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /simple/platformio/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))': /simple/platformio/
ERROR: Could not find a version that satisfies the requirement platformio (from versions: none)
ERROR: No matching distribution found for platformio
Error: Could not install PlatformIO Core: If you have antivirus/firewall/defender software in a system, try to disable it for a while.
 Command '['C:\\Users\\petra\\.platformio\\penv\\Scripts\\python.exe', '-m', 'pip', 'install', '-U', 'platformio']' returned non-zero exit status 1.

x:\~web\220131\platformio-cli-core-setup>

tried also to disable antivirus, no success....

apws avatar Feb 01 '22 17:02 apws

@apws

after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))'

Please fix this. Remove all Pythons. Restart VSCode.

ivankravets avatar Feb 01 '22 17:02 ivankravets

thank you for reply, I somehow solved it for now by deleting and reinstalling .platformio through vscode - in fact, I am trying to use it rather with CLion (and I am new into pio, ya) while solving some build problems of clean arduino leonardo or zero projects - thank you again, will try more

apws avatar Feb 01 '22 17:02 apws

Solution

If you use PlatformIO IDE, please ensure that platformio-ide.useBuiltinPython option is enabled (set to true).

Windows and macOS

PlatformIO IDE comes with built-in portable Python 3 for Windows and macOS. YOU DO NOT NEED to install Python interpreter manually. If you use PlatformIO IDE and experience this issue, please navigate to %HOME%/.platformio/python3 folder and check that python.exe (Windows) or bin/python works on your machine. In case if they don't work, please install manually the latest Python 3 using this guide. Restart PlatformIO IDE (VScode).

Linux

Please install the next package and restart IDE:

sudo apt-get install python3-venv

I still experience this issue

If you still experience this issue, please leave a comment below and describe your configuration (operating system, its version, etc.). We would be glad to help you.

Regards, Your friends at PlatformIO.

%23 Configuration

VSCode: 1.61.2 PIO IDE: v2.3.4 System: Windows_NT, 10.0.19043, x64

%23 Exception

Error: Can not find Python Interpreter. Please install Python 3.6 or above manually
  at H.value (c:\Users\Administrator\.vscode\extensions\platformio.platformio-ide-2.3.4\node_modules\platformio-node-helpers\dist\index.js:1:765899)
  at runMicrotasks (<anonymous>)
  at processTicksAndRejections (internal/process/task_queues.js:93:5)
  at async H.value (c:\Users\Administrator\.vscode\extensions\platformio.platformio-ide-2.3.4\node_modules\platformio-node-helpers\dist\index.js:1:764349)
  at async t.default.install (c:\Users\Administrator\.vscode\extensions\platformio.platformio-ide-2.3.4\dist\extension.js:1:6773)
  at async c:\Users\Administrator\.vscode\extensions\platformio.platformio-ide-2.3.4\dist\extension.js:1:12776

there is no posibillity to click on "home".... https://github.com/platformio/platformio-core-installer/issues/1967

p3moto avatar Feb 17 '22 18:02 p3moto

Hi, I have the same problem on Win 10 x64, what can I do?

Could you run platformio.exe from c:\Users\Administrator\.platformio\python3? Does it work?

Already tried this, does not change anything.

Python works, the console opens when I click one of those files: C:\Users\dartrax.platformio\python3\python.exe C:\Program Files\Python310\python.exe

It does not work when I click here (Windows Store opens): C:\Users\dartrax\AppData\Local\Microsoft\WindowsApps\python.exe C:\Users\dartrax\AppData\Local\Microsoft\WindowsApps\python3.exe

Environment variables are like this: image

Error message when aborting PlatformIO update:

Error: Can not find Python Interpreter. Please install Python 3.6 or above manually
	at u.value (c:\Users\dartrax\.vscode\extensions\platformio.platformio-ide-2.4.2\node_modules\platformio-node-helpers\dist\index.js:1:780925)
	at runMicrotasks (<anonymous>)
	at processTicksAndRejections (internal/process/task_queues.js:93:5)
	at async u.value (c:\Users\dartrax\.vscode\extensions\platformio.platformio-ide-2.4.2\node_modules\platformio-node-helpers\dist\index.js:1:783695)
	at async S.install (c:\Users\dartrax\.vscode\extensions\platformio.platformio-ide-2.4.2\dist\extension.js:1:4373)
	at async c:\Users\dartrax\.vscode\extensions\platformio.platformio-ide-2.4.2\dist\extension.js:1:28136...

Thank you!

dartrax avatar Feb 26 '22 09:02 dartrax

I have same issue as @dartrax Win10 x64, build 19042.1526. All did work just fine last week, but now it keeps complaining about Python and I can't seem to make it work, no matter what I do. Python works just fine outside PIO.

pazi88 avatar Feb 28 '22 11:02 pazi88

@pazi88 could you remove USERPROFILE_DIR/.platformio/penv and USERPROFILE_DIR/.platformio/python3 folders and restart VSCode? Do you use the latest versions of VSCode and PlatformIO IDE extension for VSCode?

ivankravets avatar Mar 05 '22 14:03 ivankravets

@ivankravets, I can't speek for @pazi88, but in my case I do not have the penv directory (I think I already tried deleting that before) and deleting the python3 directory doesn't have any effect. I will be created again when I start VS Code again and the Error pops up.

Currently, I have disabled the Platform IO extension so that this error doesn't distract me every time I use VS Code.

dartrax avatar Mar 05 '22 18:03 dartrax

@dartrax what is your OS? Did you disable the built-in PlatformIO Core + Python interpreter for the PlatformIO IDE extension in the VSCode? Please check custom extension settings and enable built-in PIO Core + Python.

ivankravets avatar Mar 06 '22 12:03 ivankravets

I have Win 10 x64, and built-in PlatformIO Core and Python are already enabled.

May be this screenshot helps, looks like if there is a syntax error somewhere...

image

dartrax avatar Mar 06 '22 16:03 dartrax

@dartrax Could you remove %USERPROFILE%/.platformio/.cache folder and restart VSCode?

ivankravets avatar Mar 06 '22 16:03 ivankravets

@ivankravets Thank you for your help! Removing the .platformio/.cache folder finally helped!

dartrax avatar Mar 06 '22 19:03 dartrax

@dartrax Could you remove %USERPROFILE%/.platformio/.cache folder and restart VSCode?

Thanks! This helped for me too.

pazi88 avatar Mar 23 '22 08:03 pazi88

3095 same issue. Cannot find interpreter, then subsequently fails.

also %HOME% does nothing on windows 10.

RFBomb avatar Mar 28 '22 13:03 RFBomb

For Windows, %USERPROFILE% instead of %HOME% should be used.

dartrax avatar Mar 28 '22 13:03 dartrax