Dyld Error Message when launching PyCharm - python

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.
Something might be broken with my Virtual Environments
Something might be broken with my PATH
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

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
Create the venv (since you have Python on your PATH)
c:\>python -m venv c:\path\to\myenv
Activate the venv (this is OS specific, see the documentation)
<venv>/bin/activate
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.
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).
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.

Related

Problems with importing netcdf4 and xarray when debugging - in eclipse + pydev on windows

I have been a staunch user of Eclipse on Windows - mostly for developing Python code. Lately, I needed to do something with the packages xarray and netcdf4. I first used an old version of Eclipse, but when I encountered problems I installed the latest LiClipse - version 8.2.0 (64 bits) on my Windows 10 machine. I use Miniconda 3 py37_4.9.2 (64 bits) with Anaconda Navigator 2.1.2 to manage my Python environments. I wrote a script of only a few lines. When I tried to import package netcdf4, I got an import error immediately that one of the netcdf4 DLLs could not be found after pressing the debug button. When I tried working without direct involvement of netcdf4 but only with xarray, I also got an import error that my packages were not configured correctly. When I started the script - outside Eclipse - from the command-line, there was no problem at all. BTW, I tried running with different Python versions: 3.6, 3.8 and 3.9 but that made no difference. I suspect that Pydev does not work together well with the packages netcdf4 and xarray. Has anybody else experienced similar problems?
It seems like some environment variable isn't properly set when running from PyDev...
Do you have the flag to load conda environment variables set in the interpreter configuration?
i.e.:
Note: if it runs in the command line you can compare the values you have in os.environ from one to the other to find what may be different (in general just making sure that the conda environment variables are loaded should do the trick, but if it doesn't comparing those and setting what's needed in the Environment tab may help).

How to install Tkinter on linux with preinstalled python but without root privilege?

Since on most linux distributions tkinter comes in a different package I have difficulties installing it on my university computer, where we don't have root access.
I get the following error:
/usr/bin/python3: Error while finding spec for 'tkinter.__main__' (<class 'ImportError'>:
No module named '_tkinter', please install the python3-tk package);
I have found this answer:
https://stackoverflow.com/a/10015546/2898702
Then I compiled and deployed TCL and TK in /home/<user>/.local
However the last step python setup.py build seems to expect, that the python interpreter is also installed in a user directory, which is not the case for me.
Is there a way to install TCL and TK without also installing the python interpreter locally? Preferably using pip or easy_install.
In case it is relevant, the distribution seems to be linux mint.
Uname -a gives me: Linux pc404 4.4.0-59-generic #80~14.04.1-Ubuntu SMP Fri Jan 6 18:02:23 UTC 2017 i686 i686 i686 GNU/Linux
For day to day working with Python, even in unrestricted environments, the way to go is to use "virtualenv", which creates a new Python environment in a user controlled folder, and you are then able to install any Python packages you want, regardless of what is available for the system. Since you have a working compiler environment, that works for almost everything.
However, tkinter itself is not available for pip install, since it is expected to come along core Python stdlib (it is about time Linux distributions would stop the idea of leaving it out - it is not like the 5MB maximum it uses would make a difference, when compared to the harm it does by not being there by default. Even customizing the Python package and creating the new one is likely more effort than it saves from anyone).
Anyway, you might try building Python in your local directory - if the system has a compiler, it probably would just work: download the tar.gz source from python.org, uncompress it and just do "./configure --prefix=/home/user/python36" . Now even when that works, it is nice to use virtualenvs for your projects.
Otherwise, you should try to find a pre-compiled Python for the specific Linux distribution, or, see in the instuctions for your package manager, if you can install Python and other packages in a different system root directory, under your control.
Anther alternative, if you have another Linux you have control, build it to a USB stick, and at the University lab, just use the ln command to link it to whatever was the target directory where you built it - that would work as a portable stick.

Which python... file directory PIP

I am sure on my Mac 0SX 10.9 I have more than one version of Python 2.7.5.
When I type in
which python
in the terminal, I get /Library/Frameworks/Python.framework/Versions/2.7/bin/python
When I am doing a pip.install it seems those are loading in a different path, they are all under /Library/Python/2.7/site-packages.
When I am in IDLE or my IDE (Sypder) and type
import sys
print sys.path
I get lots and lots of paths that start with /Library/Python/2.7/site-packages.
My problem is when I do a help() or import() on one of the modules I can see in /Library/Python/2.7/site-packages, I get a NameError: name 'Module' is not defined. Examples that I can see loaded in .../site.packages are pandas, nympy, and PyMySQL. But all give me "name of module not found".
Ideal python distribution control on a Mac: use a (free) scientific python environment like Enthought or Anaconda, and use either the real virtualenv package or the provided virtualenv package to control 'virtual environments' in which you can install packages. Virtualenvs really help keep the python distribution clean.
Good Luck.
Python development on a Mac can be a pain in the butt. That's why I set up a Arch Linux through Virtual Box and I'm quite happy with it. However, iOS development with Python using Kivy requires XCode (as far as I know) to deploy the apps on the iOS devices. So I'm in the same boot as you are.
Long story short: Running brew doctor (as in homebrew) in the terminal helped me a lot cleaning up my Python installations on the Mac.

Is it possible to write a windows service using Python?

Python has a win32service package that seems to allow windows service creation. I have carefully checked available google examples, for example this one:
Is it possible to run a Python script as a service in Windows? If possible, how?
I have placed code into ~/Documents/test.py and executed following under elevated command prompt:
> python test.py install
> python test.py debug
Unfortunately, every example i tried fails with error:
Debugging service TestService - press Ctrl+C to stop.
Error 0xC0000005 - Python could find the service class in the module
AttributeError: 'module' object has no attribute 'AppServerSvc'
(null): (null)
I have tested it with latest version of ActivePython (2.7.2.5 32-bit) on Windows 7 64-bit and Windows 8 64-bit. Of course, if service is started maually via service manager, it will not start either.
Am i doing something wrong or Python is not intended to be used for service creation on modern operating systems? Maybe i need a specific version of windows/python/pywin32? Of course, i can manually test all combinations starting from windows XP but it will take lots of time :(. Maybe someone already has experience with Python and windows services and can hint me what i'm doing wrong?
update
Tested on Windows XP 32-bit virtual macine (same code, same activepython distribution) - same error.
It appears that there is a bug in the ActiveState build for PyWin32. Installing ActiveState python 2.7.2.5 and running the linked sample code above, I get the same error that you are reporting.
But if I download Python 2.7.3 (2.7.2.5 does not seem to be available for download) and add PyWin32 build 214 (ActiveState seems to be using the 214 version of PyWin32). Then everything seems to work just fine. I also tried the latest build of PyWin32 (218) and it also worked correctly.
So I guess you can try reporting the problem to ActiveState (I don't have a support contract with them) and unless you have a requirement for using ActiveState, you can just switch to the standard Python builds.
I have been using services with the standard Python builds for years running on everything from Windows 2000 up to Server 2008 and Windows 7 with no problems. So I have good reason to believe that it will work for you also.
If you want to work with ActiveState to get the problem fixed, then the bug appears to be in their build of PythonService.cpp in the LoadPythonServiceInstance function. I looked at the registry entries that were created and they look fine, it is the PythonService.exe that is failing at loading your class. Based on the error message it appears to have loaded the module correctly and is just having trouble finding the class.

Problems building node.js on Cygwin, please help

I'm trying to get node.js running on Windows 7. I have no experience with Linux so I've just been blindly following instructions from tutorials I've found, but I'm still unable to build node.js.
What I did:
Install Cygwin - the entirety
Attempt to build node.js
This is the error I first got:
I then followed the commands of two other similar sites and they all resulted in this error (could getting several version of node have caused me more problems? I'm completely clueless on this).
I read somewhere that the Windows version of Python could be causing the problem so I uninstalled my Python 2.7 and added C:\cygwin\bin to the PATH.
That still didn't work and I read somewhere else that I'm supposed to rebaseall so I tried that, but I also got an error for that:
That's where I'm at now. Have any steps I've taken exacerbated the situation?
Add -e '/\/sys-root\/mingw\/bin/d' at line 110 in /bin/rebaseall file.
Then re-run rebaseall -v and you shouldn't get the error anymore.
See this pretty helpful blog posting - Node on CygWin doesn't work for Node v0.2.5. Use the latest v0.4.0 version instead.
Also consider the post's recommendation of compiling against MinGW instead of in CygWin.
First of all, why did you check out such an old release v0.2.5? When I did it a few weeks ago I just took the latest and ended up with 0.5.0pre, but it would also be reasonable to specify v0.4.3. For instance, type git clone git://github.com/joyent/node.git to download node, and then:
cd node
./configure
make install
Secondly, do not rebase by running ash from the CYGWIN shell. Instead, shutdown all Cygwin processes, then use Windows explorer to open the ash.exe binary. Since I have a Windows 7 system without node.js, I decided to follow my instructions and build. Not so easy. I ran into some wierd dll issues that all went away when I ran ./rebaseall followed by ./perlrebase from the ash prompt. It seems that rebaseall is not sufficient anymore.
Thirdly, there is a message that makes it sound like you don't have a C compiler. Some googling will lead you to sites telling which Cygwin packages you need, but at minimum install the g++ compiler and that should pull in C as a dependency.
When I did this I simply ran configure and every time there was an error, installed one more Cygwin package to supply the missing piece. Even OpenSSL is available.
What I just found is remove the windows based install of Python. After uninstalling this, everything is peachy.
I like cygwin a lot -- but recent releases have become pretty unreliable. Some packages just wont build, and some "standard" apps dont work e.g. gvim's "save as" bombs out on my installation.
A possible solution would be run one of the better Linux distributions (ubuntu, fedora, suse etc.) either as a virtual machine or a dual boot setup and do the build inside linux.

Categories

Resources