Closed petrkr closed 1 year ago
Unfortunately, python3
did not work on Windows, but py
does.
PS C:\> python3 --version
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
PS C:\> py --version
Python 3.11.0
So, I think this is not a simple find and replace fix. I suppose there may be a way to determine the underlying OS and adjust the executable name to suit, but I'm not sure what it is at the moment. If you have any ideas or sample code for doing that, let me know.
Seems like wrong python framework is installed in windows, there normally is python executable, do not know what kind of bundle you installed. But if you will use regular python it has python executable.
I do not have windows right now, so I can not test official release from https://www.python.org/downloads/windows/ but my college using windows and he is using python executable for sure
Pretty sure it was the download from https://www.python.org/ Interestingly, I get different versions with py
and python
and there's no python3
.
PS C:\> py --version
Python 3.11.0
PS C:\> python --version
Python 3.9.2
PS C:\> python3 --version
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
So maybe windows missing symlink/whateverlink on python3 from python.
But since python 2.x is deprecated since 2021, it can be used python without specify version at all... And if someone still have default python 2.x as python command, they probably using out-of-dated OS
I removed and reinstalled Python using the defaults given by the Windows installer. Now only py
works.
PS C:\> py --version
Python 3.11.3
PS C:\> python --version
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
PS C:\> python3 --version
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.
I think I need to dig into this further.
Tried a Linux host and got the following results:
alpine:~$ py --version
-ash: py: not found
alpine:~$ python --version
Python 3.10.8
alpine:~$ python3 --version
Python 3.10.8
alpine:~$ ls -l `which python`
lrwxrwxrwx 1 root root 16 Dec 8 20:23 /usr/bin/python -> /usr/bin/python3*
alpine:~$ ls -l `which python3`
lrwxrwxrwx 1 root root 10 Dec 8 20:23 /usr/bin/python3 -> python3.10*
It looks like python
is the most generic way to call the Python binary on Linux. I don't know if this is the same behavior you'd get on all flavors of Linux/MacOS/BSD or not, but it's a starting point.
So I'm thinking of this approach...
os.platform
PYTHON_BIN = "py.exe"
PYTHON_BIN = "python"
PYTHON_BIN --version
to verify.I installed windows 10 under VirtualBox in order to test python there. I downloaded official windows installer from python.org. Checked "Add python to PATH" before install and then both py and python commands it working fine.
I thing best solution is to use "python" command, because it works everywhere
Also tried pip to install mpremote
I added a few lines of code to check the OS type when the extension activates. If it detects Windows, it'll use py.exe
. For everything else, it will use python
.
I committed the code, but did not publish the extension yet. I was only able to test it on Windows and verify the change does not break anything, but I don't have a VS Code instance on Linux to test against.
If you want to clone the repo and test it in VS Code's debugger on Linux, that would be great. Let me know how it goes.
I never installed extension from code. I tried to check out this repo to exptensions folder and run npm install, but it seems it does not work (not see that plugin). Maybe would be faster if you have some link how to do that. Problem of VS code and google is if you search something like "extension from github" or "from source codes" it will find extensions which are working with github or git/svn/etc..
@petrkr No problem. I can just publish it. The changes don't break anything for VS Code on Windows.
@petrkr Published changes as version 0.4.4. Give it a try when you have a chance and let me know how it goes. https://marketplace.visualstudio.com/items?itemName=DavesCodeMusings.mpremote
I'm assuming this will work, but I don't have a Linux host with VS Code to test on. The changes didn't break anything in Windows VS Code, so I'm calling it good and closing the issue.
Seems this module think everybody at the whole world using windows, so this extension will NOT work in Linux nor Mac Os
Please make it platform independent by using python3 command, it should be available on every platform in PATH