virtualenv中出错 - dyld:未加载库:/ Library / Frameworks / Python.framework / Version / 3.4 / Pepy

时间:2015-10-24 08:22:18

标签: python macos virtualenv osx-elcapitan

我的virtualenv中有以下场景。

激活我的virtualenv env-trails_dj 之后
source env-trails_dj/bin/activate

并尝试启动python,我收到以下错误:

(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

virtualenv PATH如下所示:

(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

我检查了以下目录,但它是空的......

(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 ..

可能只是一个缺少的参考但我无法识别

注意:不确定是什么导致了这一点。也许升级到 OS X El Capitan(10.11.1)

更新

(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

检查启动了哪个 python 版本:

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

根据错误,python正在寻找另一个目录:

(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

1 个答案:

答案 0 :(得分:1)

看起来您的Python框架安装不正确或已删除。 您的虚拟环境在/Library/Frameworks/Python.framework/Versions/3.4/Python中查找符号链接的 python 文件。您可以输入ls -la /Users/udos/PycharmProjects/trails_dj/env-trails_dj/bin来确保这一点 - 应该有一个指向Python安装的链接。

尝试从头开始重新安装Python,然后使用:/Library/Frameworks/Python.framework/Versions/3.4/python -m venv ~/PycharmProjects/<newVirtualEnv>创建新环境或尝试使用现有环境。