Reputation:
I am using a MacBook Pro with macOS Big Sur v 11.1.
Yesterday out of nowhere I was trying to open some Python files from my terminal (e.g. $open foo.py
), and the following error and screenshot comes up:
When I try running this command using the terminal through Visual Studio code, I get an almost identical error message:
I have no idea how to go about this. One thing I tried running in a bash
terminal:
bash-3.2$ python3
Python 3.9.1 (default, Dec 17 2020, 10:08:12)
[Clang 12.0.0 (clang-1200.0.32.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>> import idlelib.idle
macOS 11 or later required !
Abort trap: 6
I do not understand this error message, as I have macOS 11.1.
EDIT: in addition to not being able to open any .py
files, I am also unable to run any .py
files either (e.g. $python3 foo.py
will not output anything even if it is supposed to).
I am able to open any other file type without any issue, even Jupyter Notebooks (.ipybn
extension), it is only .py
files that will not open.
One thing that could have happened: I was doing a practice interview and wrote a script called testInterview.py
for it. Because I cannot open the file, I cannot paste the code, but it implements a function that takes an array A
as an input and determines the smallest positive value that is not in that array. I'm new to Python, so after working on it I tried to figure out how I could run it from the command line myself, and ran the following in my terminal:
$python3 -c 'import testInterview; print testInterview.Solution(A = [1, 3, 4, 5])'
Nothing output in my terminal (it should have returned a value of 2), but it did create a __pycache__
directory. At the time I did not know what this was and figured it was just an extra file created by me running the function, so I tried removing it. Only after trying to remove it did I run into the current issue.
Upvotes: 1
Views: 806
Reputation:
After downloading Python from the website, the problem seems to have been fixed. I'm not sure why, but there seems to be a lot of bugs in Apple's version of Python, and they occurred because I did not download it from the Python website to begin with (I used Homebrew). See here for more information.
Upvotes: 1