4

I have the following scenario in my virtualenv.

after activating my virtualenv env-trails_dj with

source env-trails_dj/bin/activate

and try to launch python, I get the following error:

(env-trails_dj) AirTime:trails_dj udos$ python
dyld: Library not loaded: /Library/Frameworks/Python.framework/Versions/3.4/Python
  Referenced from: /Users/udos/PycharmProjects/trails_dj/env-trails_dj/bin/python
  Reason: image not found
Trace/BPT trap: 5

the virtualenv PATH looks as following:

(env-trails_dj) AirTime:trails_dj udos$ echo $PATH
/Users/udos/PycharmProjects/trails_dj/env-trails_dj/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

I checked the following directory but it is empty...

(env-trails_dj) AirTime:trails_dj udos$ ls -al /Library/Frameworks/Python.framework/Versions/
total 0
drwxrwxr-x  2 root  wheel   68 Jul 13 10:58 .
drwxr-xr-x  6 root  wheel  204 Jul 13 10:43 ..

maybe just a reference which is missing but I was unable to identify

note: not sure what has caused this. maybe the upgrade to OS X El Capitan (10.11.1).

update:

(env-trails_dj) AirTime:trails_dj udos$ ls -la /Users/udos/PycharmProjects/trails_dj/env-trails_dj/bin/
total 248
drwxr-xr-x  16 udos  staff    544 Sep 22 22:13 .
drwxr-xr-x   8 udos  staff    272 Oct 23 16:40 ..
drwxr-xr-x   3 udos  staff    102 Sep 11 20:26 __pycache__
-rw-rw-r--   1 udos  staff   2185 Sep 13 16:36 activate
-rw-rw-r--   1 udos  staff   1301 Sep 11 20:25 activate.csh
-rw-rw-r--   1 udos  staff   2437 Sep 11 20:25 activate.fish
-rwxr-xr-x   1 udos  staff    312 Sep 11 20:26 django-admin
-rwxr-xr-x   1 udos  staff    171 Sep 11 20:26 django-admin.py
-rwxr-xr-x   1 udos  staff    279 Sep 12 09:07 easy_install
-rwxr-xr-x   1 udos  staff    279 Sep 12 09:07 easy_install-3.4
-rwxr-xr-x   1 udos  staff    251 Sep 12 09:05 pip
-rwxr-xr-x   1 udos  staff    251 Sep 12 09:05 pip3
-rwxr-xr-x   1 udos  staff    251 Sep 12 09:05 pip3.4
-rwxr-xr-x   1 udos  staff  25920 Sep 11 20:25 python
-rwxr-xr-x   1 udos  staff  25920 Sep 11 20:25 python3
-rwxr-xr-x   1 udos  staff  25920 Sep 11 20:25 python3.4

checking which python version is launched:

env-trails_dj) AirTime:trails_dj udos$ which python
/Users/udos/PycharmProjects/trails_dj/env-trails_dj/bin/python

based on the error, python is looking in another directory:

(env-trails_dj) AirTime:trails_dj udos$ python
dyld: Library not loaded: /Library/Frameworks/Python.framework/Versions/3.4/Python
  Referenced from: /Users/udos/PycharmProjects/trails_dj/env-trails_dj/bin/python
  Reason: image not found
Trace/BPT trap: 5

update_2:

(env-trails_dj) AirTime:trails_dj udos$ pip install Python
dyld: Library not loaded: /Library/Frameworks/Python.framework/Versions/3.4/Python
  Referenced from: /Users/udos/PycharmProjects/trails_dj/env-trails_dj/bin/python
  Reason: image not found
Trace/BPT trap: 5
udo
  • 4,832
  • 4
  • 54
  • 82

1 Answers1

1

It looks like your Python framework installed incorrectly or removed. Your virtual environment looks for symlinked python file in /Library/Frameworks/Python.framework/Versions/3.4/Python. You can make sure about this by entering ls -la /Users/udos/PycharmProjects/trails_dj/env-trails_dj/bin — there should be a link to your Python install.

Try to reinstall Python from scratch, and then use: /Library/Frameworks/Python.framework/Versions/3.4/python -m venv ~/PycharmProjects/<newVirtualEnv> to make new environment or try the existing one.

  • I added an **update** section to my answer. very odd behaviour... even though the _which_ command is pointing to the virtualenv "bin" directory, executing _python_ raises the error because it can not find _python_ in the "Library" dir... – udo Oct 27 '15 at 19:08
  • Sorry for delay. This is totally what am I talking about. This line: `-rwxr-xr-x 1 udos staff 25920 Sep 11 20:25 python` should be a symlink, not a python file. It looks like this in my virtualenv: `lrwxr-xr-x 1 videopro staff 63 Sep 19 00:51 python3.5@ -> /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 ` – Alexey Bogomolov Nov 02 '15 at 15:18
  • You can do the same trick by entering `ls -GFh -la /Users/udos/PycharmProjects/trails_dj/env-trails_dj/bin`. Hope this will help. – Alexey Bogomolov Nov 02 '15 at 15:37
  • BTW, did you try to reinstall Python? There should be files in `/Library/Frameworks/Python.framework/Versions/`. I have OSX El Capitan too. Here's the link, just in case: `https://www.python.org/download/releases/3.4.0/` – Alexey Bogomolov Nov 02 '15 at 15:55
  • thanks for your support. quite a tricky task... I tried to install python via _pip_. same result... please see **update_2** – udo Nov 03 '15 at 20:25
  • Pip only installs python packages, so it requires Python, which is seems to be not installed or damaged. Use this link to reinstall Python 3.4 completely: https://www.python.org/ftp/python/3.4.3/python-3.4.3-macosx10.6.pkg. Note it is recommended to use 3.4.3 instead of 3.4.0. Then recreate your virtual environment: `python3 -m venv ~/trails_dj/env-trails_dj2` and then `source ~/trails_dj/env-trails_dj2/bin/activate` – Alexey Bogomolov Nov 05 '15 at 02:28
  • 2
    I typically avoid using the OSX system python, due to issues like this. You could get the package from python.org as @AlexeyBogomolov suggested, or (as I usually do) install homebrew from [http://brew.sh/](http://brew.sh/) and `brew install python3` At that point you should be able to recreate your virtualenv using your newly installed python3, as per Alexey. – Jessamyn Smith Mar 18 '16 at 13:45