启动 PyCharm 时出现 Dyld 错误消息 [英] Dyld Error Message when launching PyCharm

查看:169
本文介绍了启动 PyCharm 时出现 Dyld 错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几个星期以来,我一直在努力解决这个问题,但仍然卡住了.我一直在研究它并慢慢获得更多信息,但还没有解决它.

我在 Stack Overflow 上读过这些类似的问题:

dyld:库未加载:/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/Python

dyld:库未加载:/System/库/框架/CoreFoundation.framework/Versions/A/CoreFoundation

解决 PyCharm python 错误 - dyld:库未加载

问题是每次启动PyCharm都会弹出下面的错误:

进程:Python [15298]路径:/Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python标识符:Python版本:3.6.4 (3.6.4)代码类型:X86-64(原生)父进程:pycharm [14715]负责人:pycharm [14715]用户编号:501日期/时间:2021-03-27 08:19:23.857 -0700操作系统版本:macOS 11.2.3 (20D91)报告版本:12桥操作系统版本:3.0 (14Y908)匿名 UUID:130B1388-444D-6CF3-9D98-7F06C81783B0睡眠/唤醒 UUID:89450DAE-41C7-4035-B0DA-8AAB177D9DD3启动后唤醒时间:82000 秒唤醒时间:1000 秒系统完整性保护:已启用崩溃的线程:0异常类型:EXC_CRASH (SIGABRT)异常代码:0x0000000000000000, 0x0000000000000000例外说明:EXC_CORPSE_NOTIFY终止原因:DYLD,[0x1] 库丢失应用特定信息:dyld:启动,加载依赖库Dyld 错误消息:dyld:不存在共享缓存库未加载:/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation引用自:/Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python原因:找不到图片二进制图像:0x100000000 - 0x100000fff +org.python.python (3.6.4 - 3.6.4) <E585A67D-C0DB-448A-2E74-422D61BDC1C1>/Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python0x7fff639aa000 - 0x7fff63a45fff dyld (832.7.3) <0D4EA85F-7E30-338B-9215-314A5A5539B6>/usr/lib/dyld型号:MacBookPro14,2,BootROM 429.80.1.0.0,2 个处理器,双核 Intel Core i5,3.1 GHz,8 GB,SMC 2.44f6显卡:kHW_IntelIrisGraphics650Item、Intel Iris Plus Graphics 650、spdisplays_builtin内存模块:BANK 0/DIMM0、4 GB、LPDDR3、2133 MHz、0x802C、0x4D5435324C3531324D3332443250462D3039内存模块:BANK 1/DIMM0、4 GB、LPDDR3、2133 MHz、0x802C、0x4D5435324C3531324D3332443250462D3039AirPort:spairport_wireless_card_type_airport_extreme (0x14E4, 0x171),Broadcom BCM43xx 1.0 (7.77.111.1 AirPortDriverBrcmNIC-1675.1)蓝牙:版本 8.0.3d9,3 个服务,27 个设备,1 个传入串口网络服务:Wi-Fi、AirPort、en0USB 设备:USB 3.0 总线USB 设备:Apple T1 控制器Thunderbolt 总线:MacBook Pro,Apple Inc.,41.4Thunderbolt 总线:MacBook Pro,Apple Inc.,41.4

我相信在更新我的 PyCharm 安装、Python 或我的 Xcode 开发人员工具后,这开始发生.根据我的研究,我得出的结论是一些可能的问题可能导致这种情况发生.

  1. 我的虚拟环境可能会出问题

  2. 我的 PATH 可能有问题

  3. 尝试在我的计算机上管理多个 Python 版本可能会出错

关于我的情况的更多信息.

在 PyCharm 错误消息的顶部,它显示了以下行:

路径:/Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python

这似乎表明 PyCharm 可能会尝试使用 Python 3.6 启动?

当我在终端中输入 env 命令时,我得到以下输出:

PATH=/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/Users/my_name/opt/anaconda3/bin:/Users/my_name/opt/anaconda3/condabin:/anaconda3/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/Library/Apple/usr/bin

前面问题中提到的一些解决方案涉及更改 PATH 或删除/重新创建虚拟环境.

我真的不熟悉如何做这些事情.有没有人知道我可以做些什么来阻止每次启动 PyCharm 时弹出此错误消息?我是终端的新手,所以我不确定我是否理解以前的解决方案.

有没有人知道问题可能是什么或者我可以做些什么来解决这个问题?我尝试重新安装 Python 和 PyCharm,但这些解决方案都没有解决问题.

注意,我正在运行:最大操作系统:Big Sur 11.2.3蟒蛇 3.9PyCharm:社区 2020.3.4

解决方案

  1. 我的虚拟环境可能有问题

最简单的解决方案是使用 venv - 它是标准库,因此是虚拟环境的最佳基线.(为了完整起见,值得一提的是,历史上有很多解决方案.)例如 使用 PyCharm GUI 创建 venv 很容易,它从基础 Python 解释器可选择共享其 站点包.GUI 允许您与 PyPI 交互以安装其他软件包.

最终,值得学习使用命令行来做同样的事情,参见 venv — Creation虚拟环境.这归结为 3 个命令

  1. 创建 venv(因为您的 PATH 上有 Python)

    c:\>python -m venv c:\path\to\myenv

  2. 激活 venv(这是特定于操作系统的,请参阅文档)

    /bin/activate

  3. 激活后使用 pip 安装你想要的任何库

    pip install library_name

在创建并激活 venv 后,它就可以在终端上使用(在 PyCharm 内部或外部),或者您可以将它与 在 PyCharm 中运行配置.

现在,在您的情况下,您还使用 Anaconda,它为您管理包和环境.但重要的是要意识到 Anaconda 所做的大部分是将上述步骤包装在它自己的 GUI 中,请参阅与 查找您的 Anaconda Python 解释器路径.

除此之外,还有一个硬性规定,venv 不应该被复制或移动.它们内部有硬编码的路径,这些路径会中断.因此,当您创建 venv 时,请在创建它的目录中使用它.venv 的全部意义在于,如果您破坏了某些东西,您只需即时创建一个新的东西.最终,您需要编写自己的 shell 脚本来自动创建 venvs.

<块引用>

  1. 我的 PATH 可能有问题

PATH=/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/Users/my_name/opt/anaconda3/bin:/Users/my_name/opt/anaconda3/condabin:/anaconda3/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/图书馆/TeX/texbin:/图书馆/苹果/usr/bin

在 macOS/Linux 上,冒号 : 用作路径分隔符.因此,如果我们将您的 PATH 环境变量分成单独的行,我们会看到您重复使用 Python 3.9 和 Python 3.6(可能不同 微版本,通过在每个目录中运行可执行文件来检查 python --version).路径名的含义在 4 中有很好的解释.在 Macintosh 上使用 Python

为了避免任何混淆,我的 PATH 上只有最新的 Python 版本.通过激活正确的 venv,我需要的任何其他基本 Python 版本都是透明的.

您还有 Anaconda 的 bin 路径,请检查这些路径以查看 Anaconda 使哪些内容成为可执行文件.除此之外,您在 /Library/Apple/usr/bin 拥有正常的操作系统内容,它不应该干扰与 Python 开发相关的任何内容.

最后,模块发现比 PATH 中的内容更加动态.模块搜索路径 sys.path 填充了您执行脚本的路径,这意味着 directory\where_you_execute\python your_script.py 上的任何模块/包都是可发现的(您可以在运行时检查它).

<块引用>

  1. 尝试在我的计算机上管理多个 Python 版本可能会出错

这就是事情变得复杂的地方.如果您使用不同的解释器、软件包版本等...最终您将需要一个 3rd 方工具来帮助管理所有这些,这将是 AnacondaVirtualenvPoetry 等等......但本质上所有这些都是管理 venvs 添加功能和复杂性,它是学习如何手动创建和管理 venv 以更好地了解这些工具为您做什么很重要.

最后,PyCharm IDE 本身是用 Java 实现的.当您启动 IDE 时,它有自己的可执行文件,并且在极少数情况下,与 Python 解释器相关的某些东西会使 IDE 在启动时崩溃.从好的方面来说,您知道罪魁祸首是您的 Python 解释器之一,即来自错误消息:

<块引用>

Python 版本:3.6.4 (3.6.4)

具体的错误说明了一切(文件被移动,或者某些错误破坏了链接):

<块引用>

原因:找不到图像".

如果您无法启动 IDE 以从内部解决问题,请删除对有问题的解释器的任何引用通过编辑配置文件.我不知道如何确切地做到这一点,但如果您使用的是 Anaconda,则应该可以从 IDE 外部启动 Anaconda GUI 以摆脱有问题的解释器.

附带说明,如果您因 PATH 上有多个解释器而遇到问题,请使用 which python bash 命令,或 where python Windows 上的命令.这将告诉您,当您或某个应用程序在命令行上执行 python something 时,将调用 PATH 上的哪个 Python 解释器.

我认为这个问题(或其他链接问题)没有足够的信息来全面诊断问题.这需要深入了解确切的 Anaconda 配置 - 但 brew 用户也报告了同样的错误.

最可能的情况是,当您启动 PyCharm 时,解释器列表会被填充并调用 Anaconda.在升级到最新的 Python 版本后的某一时刻,现有环境之一变得不同步,因为它解析为 PATH 上以前的基本解释器(而不是硬编码到特定安装.)需要进行一般更新、删除某些内容或只是缓存需要清除的包间不兼容.

I have been trying to figure out this problem for few weeks now, but am still stuck. I have been researching it and slowly getting more information but have not been able to solve it yet.

I have read these similar questions on Stack Overflow:

dyld: Library not loaded: /usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/Python

dyld: Library not loaded: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation

Resolving PyCharm python error - dyld: Library not loaded

The problem is that every time I launch PyCharm, the error below pops up:

Process:               Python [15298]
Path:                  /Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python
Identifier:            Python
Version:               3.6.4 (3.6.4)
Code Type:             X86-64 (Native)
Parent Process:        pycharm [14715]
Responsible:           pycharm [14715]
User ID:               501

Date/Time:             2021-03-27 08:19:23.857 -0700
OS Version:            macOS 11.2.3 (20D91)
Report Version:        12
Bridge OS Version:     3.0 (14Y908)
Anonymous UUID:        130B1388-444D-6CF3-9D98-7F06C81783B0

Sleep/Wake UUID:       89450DAE-41C7-4035-B0DA-8AAB177D9DD3

Time Awake Since Boot: 82000 seconds
Time Since Wake:       1000 seconds

System Integrity Protection: enabled

Crashed Thread:        0

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    DYLD, [0x1] Library missing

Application Specific Information:
dyld: launch, loading dependent libraries

Dyld Error Message:
  dyld: No shared cache present
Library not loaded: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python
  Reason: image not found

Binary Images:
       0x100000000 -        0x100000fff +org.python.python (3.6.4 - 3.6.4) <E585A67D-C0DB-448A-2E74-422D61BDC1C1> /Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python
    0x7fff639aa000 -     0x7fff63a45fff  dyld (832.7.3) <0D4EA85F-7E30-338B-9215-314A5A5539B6> /usr/lib/dyld

Model: MacBookPro14,2, BootROM 429.80.1.0.0, 2 processors, Dual-Core Intel Core i5, 3.1 GHz, 8 GB, SMC 2.44f6
Graphics: kHW_IntelIrisGraphics650Item, Intel Iris Plus Graphics 650, spdisplays_builtin
Memory Module: BANK 0/DIMM0, 4 GB, LPDDR3, 2133 MHz, 0x802C, 0x4D5435324C3531324D3332443250462D3039
Memory Module: BANK 1/DIMM0, 4 GB, LPDDR3, 2133 MHz, 0x802C, 0x4D5435324C3531324D3332443250462D3039
AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x171), Broadcom BCM43xx 1.0 (7.77.111.1 AirPortDriverBrcmNIC-1675.1)
Bluetooth: Version 8.0.3d9, 3 services, 27 devices, 1 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
USB Device: USB 3.0 Bus
USB Device: Apple T1 Controller
Thunderbolt Bus: MacBook Pro, Apple Inc., 41.4
Thunderbolt Bus: MacBook Pro, Apple Inc., 41.4

I believe that this started to occur after updating either my PyCharm installation, Python, or my Xcode Developer tools. From my research, I have concluded that a few possible issues might be causing this to occur.

  1. Something might be broken with my Virtual Environments

  2. Something might be broken with my PATH

  3. Something might be broken trying to manage multiple Python versions on my computer

Some more information about my situation.

At the top of the PyCharm error message it shows the line:

Path:/Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python 

This seems to suggest that PyCharm might be trying to launch with Python 3.6?

When I type the env command in terminal I get the following output:

PATH=/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions
 /3.9/bin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/
Versions/3.9/bin:/Users/my_name/opt/anaconda3/bin:/Users/my_name/opt/anaconda3/condabin:/anaconda3/bin:
 /Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.6/
bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.6/
bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/Library/Apple/usr/bin

A few of the solutions mentioned in previous questions involve either changing the PATH or deleting/recreating the virtual environment.

I am really not familiar with how to do either of these things. Does anyone have any insight on what I can do to stop this error message from popping up every time I launch PyCharm? I am a novice when it comes to Terminal so I am not sure I understand the previous solutions.

Does anyone have any ideas what the problem might be or what I might be able to do to fix this? I have tried reinstalling both Python and PyCharm and neither of these solutions fixed the problem.

Note, I am running:
Max OS: Big Sur 11.2.3
Python 3.9
PyCharm: Community 2020.3.4

解决方案

  1. Something might be broken with my Virtual Environments

The easiest solution is using a venv - it's standard library and thus the best baseline for virtual enviorments. (For completness it's worth mentioning that historically there have been a number of solutions for this.) As an example creating a venv with the PyCharm GUI is easy, it creates a new interpreter from the base Python interpreter optionally sharing its site-packages. The GUI lets you interface with PyPI to install aditional packages.

Eventually, it's worth learning to do the same using the command line, see venv — Creation of virtual environments. This boils down to 3 commands

  1. Create the venv (since you have Python on your PATH)

    c:\>python -m venv c:\path\to\myenv

  2. Activate the venv (this is OS specific, see the documentation)

    <venv>/bin/activate

  3. After activating use pip to install any libraries you want

    pip install library_name

After having the venv created and activated it's ready to use on the terminal (inside or outside PyCharm), or you can use it with run configurations in PyCharm.

Now, in your case you are also using Anaconda, which manages the packages and the environments for you. But it's important to realize that what Anaconda does for the most part are the above steps wrapped in it's own GUI, see the similarities with Finding your Anaconda Python interpreter path.

Besides this, there's a hard rule that venvs should not be copied or moved. They have hardcoded paths inside them that will break. So, when you create a venv use it in the directory where you created it. The whole point of venvs is that if you break something you simply create a new one on-the-fly. Eventually, you'll want to write your own shell script to automate creating venvs.

  1. Something might be broken with my PATH

PATH=
/Library/Frameworks/Python.framework/Versions/3.9/bin:
/Library/Frameworks/Python.framework/Versions/3.9/bin:
/Library/Frameworks/Python.framework/Versions/3.9/bin:
/Library/Frameworks/Python.framework/Versions/3.9/bin:
/Users/my_name/opt/anaconda3/bin:
/Users/my_name/opt/anaconda3/condabin:
/anaconda3/bin:
/Library/Frameworks/Python.framework/Versions/3.6/bin:
/Library/Frameworks/Python.framework/Versions/3.6/bin:
/Library/Frameworks/Python.framework/Versions/3.6/bin:
/Library/Frameworks/Python.framework/Versions/3.6/bin:
/usr/local/bin:
/usr/bin:/bin:
/usr/sbin:
/sbin:
/Library/TeX/texbin:
/Library/Apple/usr/bin

On macOS/Linux the colon : is used as the path separator. So if we break your PATH environment variable into individual lines we see you have Python 3.9 and Python 3.6 repeated (might be different micro versions, check by running the executable in each directory with python --version). The meaning of the path names is well explained in 4. Using Python on a Macintosh

To avoid any mix-up I only have the latest Python version on my PATH. Any other base Python version I need is chosen transparently by activating the right venv.

You also have the bin paths to Anaconda, check inside those to see what Anaconda makes executable. Besides that you have the normal OS stuff at /Library/Apple/usr/bin which shouldn't interfere with anything related to Python development.

Finally, module discovery is more dynamic than just what's in your PATH. The module search path sys.path gets populated with the path from where you execute a script, meaning any module/package on directory\where_you_execute\python your_script.py is discoverable (you can check it at run-time).

  1. Something might be broken trying to manage multiple Python versions on my computer

Here is where it gets complicated. If you work with different interpreters, package versions, etc...Eventually you'll want to get a 3rd party tool that helps manage all that, which would be Anaconda, or Virtualenv or Poetry or etc...But essentially what all these do is managing venvs adding functionality and complexity, it's important to learn how to create and manage venvs manually to better understand what those tools are doing for you.

Finally, the PyCharm IDE itself is implemented in Java. When you launch the IDE it has its own executable and it's a rare case that something related to a Python interpreter should make the IDE crash at launch. On the up side you know the culprit is one of your Python interpreters, namely from the error message:

Python Version: 3.6.4 (3.6.4)

and the specific error says it all (either the files were moved, or some error broke the links):

"Reason: image not found".

If you can't launch the IDE to solve the problem from within get rid of any references to the problematic interpreter by editing the configurations files. I don't know how to do this exactly, but if you're using Anaconda it should be possible to launch the Anaconda GUI from outside the IDE to also get rid of the problematic interpreter.

As a side note, if you run into problems due to having several interpreters on the PATH use the which python command on bash, or the where python command on Windows. What this will tell you is which Python interpreter on your PATH is being called when you or some application execute python something on the command line.

I don't think this question (or the other linked questions) have enough info to fully diagnose the problem. It would require an in-depth look at the exact Anaconda configurations - but the same error was also reported by brew users.

The most likely scenario is that when you launch PyCharm the list of interpreters gets populated and that calls Anaconda. At one point after upgrading to the latest Python version one of the existing environments became out of synch because it resolved to a previous base interpreter on the PATH (instead of being hardcoded to a specific installation.) Something must have gone wrong by way of an inter-package incompatibility that required a general update, something was deleted, or it was just cached that needed clearing.

这篇关于启动 PyCharm 时出现 Dyld 错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆