PlatformIO IDE installer on VScode (on mac) is stuck in a loop

Hi everyone!
I am trying to install PlatformIO IDE on VScode on MacOS (python 3.7.1)
I have executed the installer from within VScode, and I get to the point that I get the message:
PlatformIO IDE installed successfully.
Please restart VSCode.
However, once I restart VScode PlatformIO IDE starts to install itself again, and it’s stuck in this loop every time I restart VScode.
I saw an old post where it was recommended to delete the ~/.platformio and that it should solve it. I did remove the folder but the installer is still looping every time VScode is restarted.

Any help will be welcomed!
Adi

When you open the developer tools (Help -> Toggle Developer Tools) is there an error message?

Yes there are errors there. I am sorry I didn’t mention it earlier, I am new to VScode (and PlatformIO).
I have attached the full error message here.
I noticed that one of the errors is because python 2.7 is being called, which is strange because when I run python from the terminal, python 3.7 is loaded. I have anaconda installed on my mac if that matters.

Do you have any suggestions how to solve the errors?

Here is the error report:

console.ts:137 [Extension Host] runCommand platformio Array(1) Object
console.ts:137 [Extension Host] Error: Error: spawn platformio ENOENT at /Users/adilavy/.vscode/extensions/platformio.platformio-ide-1.10.0/node_modules/platformio-node-helpers/dist/index.js:1:9041 at d (/Users/adilavy/.vscode/extensions/platformio.platformio-ide-1.10.0/node_modules/platformio-node-helpers/dist/index.js:1:8215) at ChildProcess. (/Users/adilavy/.vscode/extensions/platformio.platformio-ide-1.10.0/node_modules/platformio-node-helpers/dist/index.js:1:8004) at ChildProcess.emit (events.js:203:13) at Process.ChildProcess._handle.onexit (internal/child_process.js:270:12) at onErrorNT (internal/child_process.js:456:16) at processTicksAndRejections (internal/process/task_queues.js:77:11)
t.log @ console.ts:137
console.ts:137 [Extension Host] runCommand conda Array(1) Object
console.ts:137 [Extension Host] runCommand conda Array(7) Object
console.ts:137 [Extension Host] runCommand /Users/adilavy/.platformio/penv/bin/python Array(1) Object
console.ts:137 [Extension Host] /Users/adilavy/.platformio/penv/bin/python
console.ts:137 [Extension Host] runCommand /Users/adilavy/.platformio/penv/bin/python Array(1) Object
log.ts:197 ERR No application in the Launch Services database matches the input criteria.: Error: No application in the Launch Services database matches the input criteria.
console.ts:137 [Extension Host] DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at Release process - pip documentation v24.1.dev0 Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Users/adilavy/Library/Python/2.7/site-packages/pip/init.py’Consider using the --user option or check the permissions.
t.log @ console.ts:137
$logExtensionHostMessage @ mainThreadConsole.ts:39
_doInvokeHandler @ rpcProtocol.ts:398
_invokeHandler @ rpcProtocol.ts:383
_receiveRequest @ rpcProtocol.ts:299
_receiveOneMessage @ rpcProtocol.ts:226
(anonymous) @ rpcProtocol.ts:101
fire @ event.ts:587
fire @ ipc.net.ts:453
_receiveMessage @ ipc.net.ts:733
(anonymous) @ ipc.net.ts:592
fire @ event.ts:587
acceptChunk @ ipc.net.ts:239
(anonymous) @ ipc.net.ts:200
t @ ipc.net.ts:28
emit @ events.js:203
addChunk @ _stream_readable.js:295
readableAddChunk @ _stream_readable.js:276
Readable.push @ _stream_readable.js:210
onStreamRead @ internal/stream_base_commons.js:166
console.ts:137 [Extension Host] runCommand /Users/adilavy/.platformio/penv/bin/python (5) [“-m”, “pip”, “install”, “-U”, “platformio”] {}
console.ts:137 [Extension Host] runCommand platformio (6) [“-f”, “-c”, “vscode”, “home”, “–host”, “do_not_start”] {}
console.ts:137 [Extension Host] Error: spawn platformio ENOENT
t.log @ console.ts:137
$logExtensionHostMessage @ mainThreadConsole.ts:39
_doInvokeHandler @ rpcProtocol.ts:398
_invokeHandler @ rpcProtocol.ts:383
_receiveRequest @ rpcProtocol.ts:299
_receiveOneMessage @ rpcProtocol.ts:226
(anonymous) @ rpcProtocol.ts:101
fire @ event.ts:587
fire @ ipc.net.ts:453
_receiveMessage @ ipc.net.ts:733
(anonymous) @ ipc.net.ts:592
fire @ event.ts:587
acceptChunk @ ipc.net.ts:239
(anonymous) @ ipc.net.ts:200
t @ ipc.net.ts:28
emit @ events.js:203
addChunk @ _stream_readable.js:295
readableAddChunk @ _stream_readable.js:276
Readable.push @ _stream_readable.js:210
onStreamRead @ internal/stream_base_commons.js:166

I found out how to switch to Python 3.7, and now VScode indicates (on the lower left corner) that I am using Python 3.7.2 64-bit.
But when I try to install PlatformIO I still get errors, one of which is still about python 2.7…

Even with a full remove of the extension and then reinstalling it?

You might also try to use pip (or pip3) to install the PlatformIO core beforehand and retry installation, or better the installer script:

https://docs.platformio.org/en/latest/core/installation.html#super-quick-mac-linux

There are forum posts here which indicate that that’s a problem somehow.

I removed the expansion from within VScode.
I then tried the three methods mentioned in the link you shared.
All three did not work.

Using the command : python3 get-platformio.py

Installer version: 0.1.0
Platform: Darwin-18.7.0-x86_64-i386-64bit
Python version: 3.7.2 | packaged by conda-forge | (default, Mar 19 2019, 20:46:22)
[Clang 4.0.1 (tags/RELEASE_401/final)]
Python path: /Users/adilavy/anaconda3/envs/py3/bin/python3
Creating a virtual environment at /Users/adilavy/.platformio/penv
Updating Python package manager (PIP) in a virtual environment
PIP has been successfully updated!
Virtual environment has been successfully created!
Installing PlatformIO Core
/Users/adilavy/.platformio/penv/bin/python: No module named pip
Error: Could not install PlatformIO Core: Command ‘[’/Users/adilavy/.platformio/penv/bin/python’, ‘-m’, ‘pip’, ‘install’, ‘-U’, ‘platformio’]’ returned non-zero exit status 1.

Hm still anaconda. Can you temporarily change your main python3 to a normal python3 installation?

Could you try our new PIO Core installer? We have not deployed it yet to VSCode extension. Please use this installation guide/script Redirecting...

Did it help?

I tried it, but it failed. I made sure that I am using python3.7.2 (still through anaconda though).
Here is the output:

>python3 -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/develop/scripts/get-platformio.py)"
Installer version: 0.1.0
Platform: Darwin-18.7.0-x86_64-i386-64bit
Python version: 3.7.2 | packaged by conda-forge | (default, Mar 19 2019, 20:46:22)
[Clang 4.0.1 (tags/RELEASE_401/final)]
Python path: /Users/adilavy/anaconda3/envs/py3/bin/python3
Creating a virtual environment at /Users/adilavy/.platformio/penv
Updating Python package manager (PIP) in a virtual environment
PIP has been successfully updated!
Virtual environment has been successfully created!
Installing PlatformIO Core
/Users/adilavy/.platformio/penv/bin/python: No module named pip
Error: Could not install PlatformIO Core: Command '['/Users/adilavy/.platformio/penv/bin/python', '-m', 'pip', 'install', '-U', 'platformio']' returned non-zero exit status 1.
Traceback (most recent call last):
  File "<string>", line 105, in <module>
  File "<string>", line 101, in main
  File "/Users/adilavy/anaconda3/envs/py3/lib/python3.7/subprocess.py", line 347, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/Users/adilavy/anaconda3/envs/py3/bin/python3', '/var/folders/yh/6tx3vn2s4zs9bk464r5ghc000000gn/T/tmpem6ek1pi']' returned non-zero exit status 1.

I’ve disabled anaconda by removing it from the .bash_profile file (I don’t have .bash_rc).
I then re-opened the terminal window and made sure that the python version that is called is not anaconda’s.
However I still get an error, although this time the error message is saying that python3 was called (at least its not python2 anymore…).
Here is the output:

>python3 -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/develop/scripts/get-platformio.py)"
Installer version: 0.1.0
Platform: Darwin-18.7.0-x86_64-i386-64bit
Python version: 3.7.2 (default, Jan  2 2019, 10:00:57)
[Clang 10.0.0 (clang-1000.11.45.5)]
Python path: /usr/local/opt/python/bin/python3.7
Creating a virtual environment at /Users/adilavy/.platformio/penv
Updating Python package manager (PIP) in a virtual environment
PIP has been successfully updated!
Virtual environment has been successfully created!
Installing PlatformIO Core
/Users/adilavy/.platformio/penv/bin/python: No module named pip
Error: Could not install PlatformIO Core: Command '['/Users/adilavy/.platformio/penv/bin/python', '-m', 'pip', 'install', '-U', 'platformio']' returned non-zero exit status 1.
Traceback (most recent call last):
  File "<string>", line 105, in <module>
  File "<string>", line 101, in main
  File "/usr/local/Cellar/python/3.7.2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 347, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/local/opt/python/bin/python3.7', '/var/folders/yh/6tx3vn2s4zs9bk464r5ghc000000gn/T/tmpa9byjw4w']' returned non-zero exit status 1.

Could you provide an output from

ls -al ~/.platformio/penv/bin
>ls -al ~/.platformio/penv/bin
total 120
drwxr-xr-x  20 adilavy  staff   640 Mar 30 20:49 .
drwxr-xr-x   7 adilavy  staff   224 Mar 30 20:49 ..
-rw-r--r--   1 adilavy  staff  2220 Mar 30 20:49 activate
-rw-r--r--   1 adilavy  staff  1439 Mar 30 20:49 activate.csh
-rw-r--r--   1 adilavy  staff  3070 Mar 30 20:49 activate.fish
-rw-r--r--   1 adilavy  staff  1751 Mar 30 20:49 activate.ps1
-rw-r--r--   1 adilavy  staff  1161 Mar 30 20:49 activate.xsh
-rw-r--r--   1 adilavy  staff  1199 Mar 30 20:49 activate_this.py
-rwxr-xr-x   1 adilavy  staff   256 Mar 30 20:49 easy_install
-rwxr-xr-x   1 adilavy  staff   256 Mar 30 20:49 easy_install-3.7
-rwxr-xr-x   1 adilavy  staff   256 Mar 30 20:49 easy_install3
-rwxr-xr-x   1 adilavy  staff   247 Mar 30 20:49 pip
-rwxr-xr-x   1 adilavy  staff   247 Mar 30 20:49 pip3
-rwxr-xr-x   1 adilavy  staff   247 Mar 30 20:49 pip3.7
lrwxr-xr-x   1 adilavy  staff    35 Mar 30 20:49 python -> /usr/local/opt/python/bin/python3.7
lrwxr-xr-x   1 adilavy  staff     6 Mar 30 20:49 python3 -> python
lrwxr-xr-x   1 adilavy  staff     6 Mar 30 20:49 python3.7 -> python
-rwxr-xr-x   1 adilavy  staff   234 Mar 30 20:49 wheel
-rwxr-xr-x   1 adilavy  staff   234 Mar 30 20:49 wheel-3.7
-rwxr-xr-x   1 adilavy  staff   234 Mar 30 20:49 wheel3

Strange issue, please run this:

~/.platformio/penv/bin/python -m pip list

if it does not work,

~/.platformio/penv/bin/pip list

It seems that we can fix this issue on our side. Please provide info mentioned above. Thanks!

The first part did not work:

> ~/.platformio/penv/bin/python -m pip list
/Users/adilavy/.platformio/penv/bin/python: No module named pip

The second gives this output:

> ~/.platformio/penv/bin/pip list
Traceback (most recent call last):
  File "/Users/adilavy/.platformio/penv/bin/pip", line 5, in <module>
    from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip'

Hm, I’ve not expected this result :frowning:

Could we try to create virtualenv manually?

rm -rf ~/.platformio/penv
/usr/local/opt/python/bin/python3.7 -m venv ~/.platformio/penv
~/.platformio/penv/bin/pip --version
~/.platformio/penv/bin/pip list

Does this work now?

I’ve encountered an error when creating the virtual env.

> /usr/local/opt/python/bin/python3.7 -m venv ~/.platformio/penv
Error: Command '['/Users/adilavy/.platformio/penv/bin/python3.7', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

I did check and python3.7 exists in /usr/local/opt/python/bin/

It looks like brew’s python is broken. Could you try to run

brew update
brew upgrade

It should upgrade your Python. Now, just use PIO Core installer script again.

I’ve executed both commands which resulted in a bunch of updates.
Python was updated to 3.7.7
I’ve removed the old .platformio folder for a clean install, and then used:

python3 -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/develop/scripts/get-platformio.py)"

Which resulted in an error again:

Installer version: 0.1.0
Platform: Darwin-18.7.0-x86_64-i386-64bit
Python version: 3.7.7 (default, Mar 10 2020, 15:43:03)
[Clang 11.0.0 (clang-1100.0.33.17)]
Python path: /usr/local/opt/python/bin/python3.7
Creating a virtual environment at /Users/adilavy/.platformio/penv
Updating Python package manager (PIP) in a virtual environment
PIP has been successfully updated!
Virtual environment has been successfully created!
Installing PlatformIO Core
/Users/adilavy/.platformio/penv/bin/python: No module named pip
Error: Could not install PlatformIO Core: Command '['/Users/adilavy/.platformio/penv/bin/python', '-m', 'pip', 'install', '-U', 'platformio']' returned non-zero exit status 1.
Traceback (most recent call last):
  File "<string>", line 105, in <module>
  File "<string>", line 101, in main
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 363, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/local/opt/python/bin/python3.7', '/var/folders/yh/6tx3vn2s4zs9bk464r5ghc000000gn/T/tmp7zwdz4cl']' returned non-zero exit status 1.

I then tried the two commands you asked me to test earlier:

> ~/.platformio/penv/bin/python -m pip list
/Users/adilavy/.platformio/penv/bin/python: No module named pip
> ~/.platformio/penv/bin/pip list
-bash: /Users/adilavy/.platformio/penv/bin/pip: No such file or directory

and also

ls -al ~/.platformio/penv/bin
total 24
drwxr-xr-x  8 adilavy  staff   256 Apr  2 18:52 .
drwxr-xr-x  8 adilavy  staff   256 Apr  2 18:52 ..
-rw-r--r--  1 adilavy  staff  2211 Apr  2 18:52 activate
-rw-r--r--  1 adilavy  staff  1263 Apr  2 18:52 activate.csh
-rw-r--r--  1 adilavy  staff  2415 Apr  2 18:52 activate.fish
lrwxr-xr-x  1 adilavy  staff     9 Apr  2 18:52 python -> python3.7
lrwxr-xr-x  1 adilavy  staff     9 Apr  2 18:52 python3 -> python3.7
lrwxr-xr-x  1 adilavy  staff    44 Apr  2 18:52 python3.7 -> /usr/local/Cellar/python/3.7.7/bin/python3.7

By the way, thank you so much for helping me out with this issue!!

Interesting case, I just can imagine what is going with your machine. I have some ideas but do not want to request sensitive info from your machine, such as system PATH and Python 3.7 sys.path.

Do you see any files here ~/.platformio/penv/lib/python3.7/site-packages/pip

ls -al ~/.platformio/penv/lib/python3.7/site-packages/pip

There are no files in ~/.platformio/penv/lib/python3.7/site-packages

ls -al ~/.platformio/penv/lib/python3.7/site-packages/
total 0
drwxr-xr-x  2 adilavy  staff  64 Apr  2 18:52 .
drwxr-xr-x  3 adilavy  staff  96 Apr  2 18:52 ..