6

I've been using Python 2.7.10 in a virtualenv environment for a couple of months.

Yesterday, activating the environment went fine, but today suddently I get this cryptic error when trying to start Python from Terminal:

Illegal instruction: 4

I have made no changes to my environment (AFAIK), so I'm having a difficult time trying to come to terms with what this error is and what caused it.

Python works fine outside of this virtualenv environment. When running via /usr/local/bin it presents no problem.

tkausl
  • 13,686
  • 2
  • 33
  • 50
P A N
  • 5,642
  • 15
  • 52
  • 103
  • I don't know the answer, but that's the same crash you'd get if you bundled an executable within a Sandboxed OSX app and attempted to run the executable directly from the command line... – trojanfoe Nov 17 '15 at 10:33
  • In this newer similar question, a solution is suggested: https://stackoverflow.com/q/48710094/5802289 – J0ANMM Mar 09 '18 at 10:41

2 Answers2

1

I've had this problem a number of times now. While I can't say for certain what the actual issue is, I believe it basically means that some file(s) in the virtualenv installment of Python have become corrupted.

I keep my virtual environment in a synced Dropbox folder, so that may be a large contributor to the issue.

Restoring the virtual environment from a back-up archive worked for me. Or simply reinstall an identical virtual environment.

  • First, try activating the faulty environment by cd <path/to/old_env> and source /bin/activate.
  • If it's successfully activated, cd to an accessible location on the drive and run pip freeze > requirements.txt to export a list of currently installed Python modules.
  • Delete the old environment.
  • Install a new virtual environment of the latest version of Python 2 that you have on the computer, via virtualenv <path/new_env>
  • Or, if you want to use a specific Python version, first make sure you have you have it on your drive, and then do virtualenv -p <path>. Assuming that you have downloaded the Python version with Homebrew, e.g.: virtualenv -p /usr/local/bin/python2.6 <path/new_env>
  • Activate the virtual environment via cd <path/new_env> and then do source /bin/activate.
  • Assuming that you kept a list of modules to reinstall by previously doing pip freeze > requirements.txt, cd to the folder where the text file is located and do pip install -r requirements.txt.
  • Otherwise, reinstall the modules with pip manually.
P A N
  • 5,642
  • 15
  • 52
  • 103
1

I had same problem and found solution by uninstalling psycopg2 and installing older version. As I understood my comp was not supporting some commands in new version