I recently change my laptop, windows to mac.
I downloaded python and vscode and install python extension as i did on windows.
Then i edited task json file to use cmd +shift +b for building shortcut.
However when i build the file, there's an error saying on terminal "zsh:command not found:python".
What should i do?
I researched and knew maybe i have to change default app, python to python3, but don't know how.
Actually i'm not certain this is the problem.
You need to add python to zsh by running the following in the terminal:
echo "alias python=/usr/bin/python3" >> ~/.zshrc
Related
I am using the application vs code, and whenever I try to run a python file, it gives me the error:
zsh: command not found: python
I have the python extension and application installed on my computer. I am using a MacBook with the new M1 Chip.
The code is just:
print("Hello World")
Does anyone know how to fix this?
Because the command character used in MAC is python3 instead of python.
You can echo "alias python=/usr/bin/python3" >> ~/.zshrc in terminal to alias "python" with "python3".
You can refer to the document for more information about the use of vscode on macOS
I'm having an issue using Python in my Mac Terminal Shell.
I used Python through Mac Terminal yesterday, but after I worked in Pycharm this morning, there seems to be an issue with my terminal.
Now when I simply write 'python', I receive this message:
zsh: no such file or directory: /usr/local/bin/python3.7
Any help, getting me back to using Python in my terminal would be appreciated!
Apparently the PATH of your S.O. It can't find the file to launch Python in your terminal so you could:
reinstall Python from the command line (zsh) and validate the "python" command again from the terminal
find the file associated with Python with commands like "find" and then modify the path of the PATH to the path where the Python launcher is
Pycharm has a tendency of changing your PATH after installation.
You have basically 3 options:
Option 1: Reinstall Python and use the path for both pycharm and zsh
I recommend this. It's a little bit of work, but you have a messy situation right now and completely kicking python off the system and then setting the PATH in your bash_profile and Pycharm is cleaner than the other options.
Uninstall Python. Make sure not to touch MacOS system Python.
Install Python
Path in Pycharm
Option 2: Find the path, Pycharm uses and set it in your bashprofile
See 1.3.
Option 3: Install Python and run it separately to the python path pycharm uses.
See 1.2
I just installed my ubuntu on my PC then i installed python 3 & Vscode on my PC. but my VS Code didn't recognize the python3. maybe my vs code looking for my python. how to solve this?
In my VS Code when I compiled the class then the output:
python -u "/home/kisiniki/Documents/python/tempCodeRunnerFile.py"
/bin/sh: 1: python: not found
In my terminal already installed python 3.6.8.
First, try to see if you are able to run the same command in terminal.
python -u "/home/kisiniki/Documents/python/tempCodeRunnerFile.py"
If you are getting the same error, "python: not found", then likely python installation was not completely successful, you can either uninstall and reinstall or you can try to update PATH to contain the folder containing the python executable. See https://askubuntu.com/questions/637848/how-to-reset-python-path-to-usr-bin-python for more detail.
If you can run the command in terminal, then that means VS Code cannot find your installed python. See if you need to edit some settings in VS Code for it to know what python executable to run. See
https://code.visualstudio.com/docs/python/environments for more detail.
It's probably because you used the command python without having an activated virtual environment or not using python3 or python3.6. Try it with python3.6 and see if that fixes it. If it doesn't then Python isn't on your PATH.
My linux distribution(Opensuse 42.2) comes with python 2.7 already installed, however I installed python3 on top of that. And in order to launch IDLE to run the python3 shell, I was told to install "python3-tools" and then just run "idle3" in terminal to launch the shell. However running "idle3" in terminal only brings up an error message, and I can't find any other suggestions. Any help would be extremely appreciated.
** I have fixed the problem. The sources that I found gave me the improper package name. After searching the main-repository for Opensuse, the proper package name for python3 IDLE was "python3-idle".
I installed python 3.2 edition, but when I opened wingIDE, my MAC still only show the old edition phthon 2.6.1. I tried to use "configure python"-enter python3.2 in "python executable", then found nothing changed, python 2.6.1 still appeared in wingIDE. Any suggestion?
I just tried to launch WINGIDE again and this time it indicates the python 3.2, the newest edition i installed. hmmmm, funny, i didn't change anything and it recognized it now! But when i use terminal, it still only recognize python 2.6.
Is python3.2 in your PATH? Try typing "python3.2" at the command line and see if that works. Where is python3.2 located? It's probably /usr/bin/python3.2 Try using that in WingIDE and see if that works.
This may depend on the version of OSX you are running. I did a custom install of python 2.7 on my machine running 10.6.7 and had to modify ~/.bash_profile with the following line:
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
You may want to check the directory /Library/Frameworks/Python.framework/Versions and see what the full path is to your 3.2 install. You could then modify the PATH variable in your ~/.bash_profile like this:
PATH="/Library/Frameworks/Python.framework/Versions/YOUR_VERSION_NUM/bin:${PATH}"
trying to fix wing myself, but if you want to just execute it via commandline...
in terminal:
python3.2 ./filename.py
enjoy
The reason is because the "python" shortcut doesn't exist in "/Library/Frameworks/Python.framework/Versions/3.4/bin", which is the newly created binary location.
Create a soft link to "python" as a work around.
"ln -s python python3.4".
Also, make sure that your .bash_profile has an entry for /Library/Frameworks/Python.framework/Versions/3.4/bin directory.
Verify with "Python -V"