I have an old iMac running High Sierra and I use the Anaconda distribution of python 3.7. I've been using Anaconda for over 2 years and it has worked fine. I have a test code I've run over 100 times to be sure my python still works after doing something stupid on my computer. About a week ago I was trying to get a python script to run and input some bad parameters into the code. This appeared to lock up my computer and without thinking I manually restarted my computer.

Now I can't seem to get python to work no matter what I do. Before this I had run python scripts using Atom and VSCode. Both worked fine and I checked both out with my test code many times. I would also run Python from the command line and it worked fine as well. Now when I try to run a script in Atom or VSCode it doesn't work. Sometimes it gives me an "Illegal instruction: 4" message. And other times I get "No module named vpython found. Even though I installed vpython on my machine using conda install vpython.

When I run my test code from the terminal I get an immediate return which says "Illegal instruction: 4". My test code doesn't use vpython.

I have deleted and reinstalled the Anaconda Python twice. I do not have time machine working on my computer so I'd like to fix this issue. Does anyone know why I keep getting the illegal instruction 4 when I run from the command line?


  • macOS 10.13.6
  • Python:

    which python3

I just wrote a simple script and it ran fine in the terminal. The script read in a number and printed it back out and also printed version of python it was using. The source code is:

num = int(input("Enter a number: "))    
import sys 

Adding any one of these three lines to the above script causes the illegal instruction 4 output.

import numpy as np
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt

So it seems to be something due to these import commands. Although import system works fine!

  • @jmh can you run a simple print statement using the interactive python in Terminal, invoked by python3? So that we know that python works or not. If it works, we'd need to see the script.
    – anki
    Commented Apr 20, 2020 at 6:47
  • @ankii I wrote a simple 4 line code and it working fine in the terminal. i've edited my answer and included the 4 lines of code.
    – Natsfan
    Commented Apr 20, 2020 at 15:35
  • 1
    Please add your iMac model (e.g. iMac11,2; 3.2 GHz)! I think traced the problem: missing AVX support of your processor....
    – klanomath
    Commented Apr 21, 2020 at 0:57
  • It would be useful to use a static checker as this one: github.com/python/mypy. Possibly you split a word and now it shows error. Please note that in import sys print(sys.version) - print is not allowed to be on same line with import keyword, it is marked as error when checking with mypy.
    – Yoan
    Commented Apr 23, 2020 at 6:38
  • import sys and the print statements were on different lines. When i pasted them into my question they merged.
    – Natsfan
    Commented Apr 23, 2020 at 15:02

1 Answer 1


I found a solution but I'm not 100% sure its the whole answer. My test codes now run fine. I very carefully reloaded the Anaconda distribution for python 3.7 and i made sure to activate my virtual environment ASAP. When Anaconda is loaded, it also loads many packages. I noticed that it did not load numpy, although it had in the past. It did load something called numbpy, I think it was. Anyway, making sure my virtual environment was activated I loaded numpy for my environment by typing:

conda install -n yourenvname [package]

I also did the same for vpython. Now everything seems to work. I suppose the problem was trying to import a package that hadn't been installed properly. I'm sure I've committed the foul-up before but I don't recall ever seeing "Illegal instruction 4".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .