0

I just updated my Mac to "Big Sur" Version 11.6. Unfortunately, after doing this I can no longer run Python. I tried un-installing and re-installing Python and believe that I have done this successfully: running python3 -V yields the message Python 3.8.2. However, whenever I run a Python file in PyCharm, I now get an an error message like

Error running 'randomfile': Cannot run program "/Users/my_name/Desktop/my_folder/venv/bin/python" (in directory "/Users/my_name/Desktop/my_folder"): error=2, No such file or directory

To clarify, I can still run these Python files if I do this in the command line, e.g.

cd /Users/name_name/Desktop/my_folder
python3 randomfile.py

However, while I can run these files, I can't seem to do this any more in PyCharm.

Can anyone explain what I am doing wrong here? As I say, there was no problem before the Mac update.

Edit: I believe that the problem is somehow caused by the Python interpreter, or lack of. When I try to add a Python interpreter, I get the error message:

Invalid Python SDK

Does anyone know how I might go about fixing this?

Edit 2: In case it is helpful to anyone else: I just managed to fix this by deleting and re-creating my virtual environment.

afreelunch
  • 130
  • 6
  • 1
    Did you delete your virtual environment? – Abhyudaya Sharma Oct 12 '21 at 11:39
  • I don't think so... but it is possible that I did it by accident. (As you will have guessed, I am not an expert in these matters!) Is there a way in which I can check? And if I did delete it (and have done this for all my Python files), is there an easy way to undo this? – afreelunch Oct 12 '21 at 11:39
  • `ls -alR /Users/name_name/Desktop/my_folder` should print out the contents of your directory – Abhyudaya Sharma Oct 12 '21 at 11:42
  • on my Mac, I just write `python` (not `python3`), have you tried that? – askman Oct 12 '21 at 11:44
  • @AbhyudayaSharma I don't believe this is the problem: I just re-downloaded the code from GitHub, and the problem persists. Also, I can see a "venv" file with "bin" and "lib" files also. – afreelunch Oct 12 '21 at 12:04
  • `venv` should be a folder not a file... can you check that? Also consider just rebuilding your virtual environment – Matteo Zanoni Oct 12 '21 at 12:19
  • 1
    It's a virtualenv, when underlying Python installation changes, it breaks. Delete the virtualenv and create it anew (`python -m venv ./venv/target/folder`) – yedpodtrzitko Oct 12 '21 at 12:19

0 Answers0