zsh: killed python3 on M1 MacBook Pro - python

I'm trying to run Python 3 on the new M1 chip MacBook. I tried installing python3 both via the official Python website (https://www.python.org/downloads/release/python-391/) and also via brew install python3. Both of the installations succeeded, however when I try running the command python3 in Terminal I get this error:
zsh: killed python3
Does anyone know what's going on? I couldn't find anything online and I think my installation should be fine. I did have to change my ~/.zshrc file for a class, but I'm not sure if that's the issue?

I faced this same issue in the M1 Macbook pro and fixed it by doing the following
Open ~/.zshrc file (Create a new one if not present already)
Add the following line
alias python3="/usr/bin/python3"
Make sure you are able to access python3 from the above location by running
/usr/bin/python3
This should invoke Python3 for you or check for the correct path in /usr/bin and update the above line accordingly. You can do the same for other versions of Python also accordingly.

Try reinstalling python and all dependencies using homebrew!
brew reinstall $(brew deps python3) python3

I started to face the same issue myself while on M1 chip MacBook with macOS Monterey. I was using VS code to try to run my python script and it worked fine. But when I tried it on the terminal I kept getting that same response.
The simple solution that I found to work was specifying which python version I was running. Ex: say I have a file named testing.py and I am running the latest version of python 3.X, then in my terminal I would do
python3.X testing.py
and everything seemed to run just fine (at least for me).
Enjoy

I got a same error. Then I disabled MacOS System Integrity Protection(SIP), python3 runs correctly.

Related

Numpy fails in Pycharm but runs on VSCode/terminal M1 Mac

My code uses matplotlib which requires numpy. I'm using pipenv as my environment. When I run the code through my terminal and pipenv shell, it executes without a problem. I've just installed Pycharm for Apple silicon (I have an M1) and set up my interpreter to use the same pipenv environment that I configured earlier. However, when I try to run it through Pycharm (even the terminal in pycharm), it throws me the following error:
Original error was: dlopen(/Users/s/.local/share/virtualenvs/CS_156-UWxYg3KY/lib/python3.8/site-packages/numpy/core/_multiarray_umath.cpython-38-darwin.so, 0x0002): tried: '/Users/s/.local/share/virtualenvs/CS_156-UWxYg3KY/lib/python3.8/site-packages/numpy/core/_multiarray_umath.cpython-38-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
What's confusing me is the fact that my code executes when using this same environment through the my terminal... But it fails when running on Pycharm? Any insights appreciated!
Macs with m1 chips have something called Rosetta. This is basically simualting the architecture of Intel and Amd chips. When you click on the properties of your terminal there should be an option to open the terminal with Rosetta.
I had the same problem already, in each IDE you can set if the script should be run with imulatation (Rosetta) or without. So you should look up how to tell pycharm to use Rosetta.
Set the "shell path" under preferences - tools - terminal:
env /usr/bin/arch -x86_64 /bin/zsh --login
that should fix it
The problem ended up being the python version I had installed. Since I upgraded from intel to M1, the python version also carried over. Downloading a new 3.10 version and creating a new interpreter for it solved this issue.

VScode didn't recognize python3

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.

IDLE3 installed for Python however I can't open it

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

ImportError: No module named tflearn

Above Error comes only when i am trying to run the script : "rgarg:pytutorial raghav$ python tflearn11.py"
It working fine in Rodeo IDE, also if I put "import tflearn " in command line python interpreter it works fine (even I typed full script in command line , it worked fine w/o import issue) .
My packages are in same location as i have given in my bash (Mac OS El Captain)
export PYTHONPATH=$PYTHONPATH:/usr/local/lib/python2.7/site-packages
A similar problem i found Link but not getting how can i remove path(0) when running from python interpreter.
Thanks
As #Two-Bit mentioned i used virtualenvs Link.
But please make sure use below for installation of virtualenvs
$ sudo easy_install virtualenvs
instead of pip install virtualenvs.

python 3.2 installed, but MAC didn't recognize it

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"

Categories