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

Can not find Python Interpreter #1774

Open
ZengShifeng opened this issue Oct 21, 2021 · 92 comments
Open

Can not find Python Interpreter #1774

ZengShifeng opened this issue Oct 21, 2021 · 92 comments

Comments

@ZengShifeng
Copy link

ZengShifeng commented Oct 21, 2021

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
@ivankravets
Copy link
Member

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

@ivankravets ivankravets changed the title Installation Manager Error: Can not find Python Interpreter. Please install Python 3.6 or above manually Nov 4, 2021
@ivankravets ivankravets pinned this issue Nov 4, 2021
@ivankravets ivankravets changed the title Error: Can not find Python Interpreter. Please install Python 3.6 or above manually Can not find Python Interpreter Nov 4, 2021
@ivankravets ivankravets added help wanted Extra attention is needed known issue and removed help wanted Extra attention is needed labels Nov 4, 2021
@SaturdayScience
Copy link

Thank you Platformio seems to be installed OK

@scorninpc
Copy link

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
Copy link

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

@swanlm
Copy link

swanlm commented Jan 9, 2022

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?

@ivankravets
Copy link
Member

@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 ?

@swanlm
Copy link

swanlm commented Jan 9, 2022

@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...

@ivankravets
Copy link
Member

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

@swanlm
Copy link

swanlm commented Jan 9, 2022

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):

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)

@ivankravets
Copy link
Member

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.

@domdfcoding
Copy link

If I click the "I have python" button in the dialog and select the correct interpreter (which has the venv module) it continues to try to use a different interpreter without the venv module every time the window reloads.

@domdfcoding
Copy link

After downgrading the extension to 3.2.0 everything works fine though

@BartLH
Copy link

BartLH commented Sep 6, 2023

I can confirm the same as @domdfcoding, I get this error with the latest version (3.3.1) but not with 3.2.0. This is a clean install in VS Code on Ubuntu 20.04 with conda (I don't have access to modify the system python and don't use it).

@ivankravets
Copy link
Member

We don't support conda. Does Installer Script work for you?

@BartLH
Copy link

BartLH commented Sep 7, 2023

No, because even though the docs explicitly say "PlatformIO operates without the need for administrative or sudo permissions.", the first instruction in this issue is sudo apt-get install python3-venv...

Installing PlatformIO Core (CLI) and using only the cli commands works fine with pip install platformio in a conda env, so I don't see why conda wouldn't be supported. Does the IDE extension need something else than the core installation?

That standalone core installation can not be used in VS Code because the installer scripts are broken if "platformio-ide.useBuiltinPIOCore": false is set.
Related: #2284 (comment)

@ivankravets
Copy link
Member

@BartLH, the reason why we don't support Anaconda is a custom unofficial Python distribution. As a result, many system-dependent packages that have pre-built binaries do not work with "conda". Shortly, conda's Python != official Python. They have a fork and patch Python with their own things which are not interesting for us and it is difficult to maintain them.

@zerovijay
Copy link

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

its work for me after install this my ide back to normal

@Utopists
Copy link

This 'Cannot find Python Interpreter' issue arose while trying to remedy another mysterious unprovoked problem probably arising from OS and VS upgrades. Dutifully following all the various online advice its taken two days involving repeatedly resinstalling Linux, VS and supporting software etc. The final act was to use your 'sudo apt-get install python3.venv' command above on my Asus Chromebook. You need to flag the implications of changes and required remedies much more assiduously. I have infinite patience (and loyalty) but over the last period I've spent far more time maintaining my working environment than actually creating new code.

@JamesNewton
Copy link

Very much agree with @Utopists . I gave up and went back to Arduino IDE 1.89. Sick of spending all my time on things that I never wanted to change anyway.

@ivankravets
Copy link
Member

@JamesNewton, what is your OS?

@JamesNewton
Copy link

@ivankravets
It was Ubuntu 16.04. I've since upgraded to 22, but haven't bothered to move off Arduino IDE since it works everywhere. Or at least 1.89 does. v2 Arduino IDE also broke things for me.
#1038 (comment)
and then
#1038 (comment)

@iremkalkanli
Copy link

Hi I have similar issue with the system I read all the comments and apply the solutions that I thought I had similar setup.
I use windows 11
vscode : 1.83.1
platformio: 3.1.1

@ghost
Copy link

ghost commented Oct 26, 2023

SOLUTION FOUND !

If you're reading this, you've probably tried everything, but still cant get it to work. Worry no more! I'm 99% sure this will fix the problem we've all been facing!

STEP 1:
Install any Python version 3.6 or above.
STEP 2:
Type into the search bar on the bottom left of your screen "python" until you find your desired Python application, then, right click it and select "Open file Location." This will bring you to it's shortcut; right click it and again, select "Open file Location."
STEP 3:
Go into the parent folder (press the left arrow top left of file explorer) and copy it. (Copy the parent folder, it should be named Python+the version)
STEP 4:
Go into "C:/Users/your username/.platformio/" and delete the folder named "python3." Now, paste the folder you copied earlier and rename it to exactly "python3"

Finally, make sure to restart VSCode if it's open, and Voila! Sit back and relax, as platformIO installs as it should.

@iremkalkanli
Copy link

I tried what you said but it is still not working -Vscode still can't see the python interpreter- thanks for the answer though

@ivankravets
Copy link
Member

@iremkalkanli , please open cmd.exe and share the output of the following command:

python -c "import sys; print(sys.executable)"

or

python -c "import sys; print(sys.executable)"

@iremkalkanli
Copy link

@ivankravets

Ekran görüntüsü 2023-10-30 075128

@ivankravets
Copy link
Member

Could you try to run the installer script manually? See https://docs.platformio.org/en/latest/core/installation/methods/installer-script.html#local-download-macos-linux-windows

Do you see any errors?

@iremkalkanli
Copy link

I don't see any errors related to installation
image
But still it can't detect the python interpreter

@ivankravets
Copy link
Member

Could you open cmd.exe and type C:/Users/yonga-it-082/.platformio/penv/Scripts/platformio.exe boards. Does this command work for you?

@iremkalkanli
Copy link

iremkalkanli commented Nov 6, 2023

image
I think it works @ivankravets

@OriginalCREart
Copy link

I had the same issue, but I have noticed that the Ubuntu WSL is active, if you are on windows, just close the remote connection, and then you can run PlatformIO without issues. THIS WAS MY CASE

image

After disabling Ubuntu WSL thing!

image

Hope this will help!

@AmshaSharam
Copy link

After long time i find that my "COMODO Firewall" was blocking platformio acess to python, check yours.

@neutronstriker
Copy link

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

even though the below code doesn't yield expected result, after install install venv and pip using "sudo apt install python3-venv python3-pip" the issues seems to be resolved.
python3 -c "import venv; import ensurepip; print('Congrats! Python venv is already installed!')"

@WahomeKennedy
Copy link

Thank you so much for this, after running sudo apt-get install python3-venv the problem was fixed on Ubuntu. I am currently learning ROS.

@AncientTree
Copy link

Dosen't work for Windows

@chegewara
Copy link

@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 ?

I had issue to start with platformio on Ubuntu 24.04 due to missing setuptools package.
This answer gave me a hint and this command solved my problems:
~/.platformio/penv$ bin/pip install setuptools

@emielsteerneman
Copy link

Installing python-venv solved the issue for me after a very frustrating hour of putting my python path /usr/bin/python in any setting even slightly related to its path, trying multiple platformio versions, rebooting, etc etc. Can the error be made more specific, saying that it can't find python-venv instead of it incorrectly saying it can't find python?

@themanyone
Copy link

themanyone commented Nov 8, 2024

I encountered this today and just blew out all the configs in ~/.vscode and ~/.config/Code.
All customizations are now kaput. But at least nothing works now.

Linux, Fedora 39. venv installed, along with ensurepip. Visual Studio Code.

Error: Can not find Python Interpreter. Please install Python 3.6 or above manually at MA.whereIsPython (/home/k/.vscode/extensions/platformio.platformio-ide-3.3.3-linux-x64/node_modules/platformio-node-helpers/dist/index.js:1:961177) at async MA.install (/home/k/.vscode/extensions/platformio.platformio-ide-3.3.3-linux-x64/node_modules/platformio-node-helpers/dist/index.js:1:964300) at async k.install (/home/k/.vscode/extensions/platformio.platformio-ide-3.3.3-linux-x64/dist/extension.js:1:9248) at async /home/k/.vscode/extensions/platformio.platformio-ide-3.3.3-linux-x64/dist/extension.js:1:45104...

So I edited those files. Manually removed the error throws. Got this. Looking for envs

Cannot read properties of undefined (reading 'envs')

Linux, Fedora 39. venv installed, along with ensurepip. Visual Studio Code.

I clicked around on some more errors and got sent here, where it said to install pio home. platformio/platformio-vscode-ide#3408

Now PlatformIO comes up in Firefox. Restarted VSCode. Still stuck at Installing PlatformIO Core.

I think trying to make it work inside VSCode is a dead end. The website says I can run platformio run on the project from the command line. It appears to be downloading some toolchain stuff and building the Marlin project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests