当前位置: 代码迷 >> python >> virtualenv中引发的错误-dyld:未加载库:/Library/Frameworks/Python.framework/Versions/3.4/Python
  详细解决方案

virtualenv中引发的错误-dyld:未加载库:/Library/Frameworks/Python.framework/Versions/3.4/Python

热度:124   发布时间:2023-06-16 10:05:12.0

我的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

看来您的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>创建新环境或尝试现有环境。

  相关解决方案