DearPyGui icon indicating copy to clipboard operation
DearPyGui copied to clipboard

ImportError - Reason: image not found

Open ZedOud opened this issue 3 years ago • 16 comments

Version of Dear PyGui

Version: 1.0.2 Operating System: macOS 10.15.7

My Issue/Question

Attempting to import the library fails. I have checked the FAQ and issues list (and found a failed issue submission).

To Reproduce

Steps to reproduce the behavior:

import dearpygui.dearpygui as dpg

Attempted in Python 3.9 and 3.10 Attempted running the demo from IDLE and from Terminal. Attempted as a statement in the Python shell.

What I have installed:

~ % pip3.10 list
Package    Version
---------- -------
dearpygui  1.0.2
pip        21.3.1
pyparsing  2.4.7
setuptools 57.4.0
tqdm       4.62.2

Expected behavior

I would expect the import statement to not fail.

Screenshots/Video

Screen Shot 2021-11-02 at 10 08 06 PM
Traceback (most recent call last):
    File "<pyshell#0>", line 1, in <module>
        import dearpygui.dearpygui as dpg
    File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/dearpygui/dearpygui.py", line 22, in <module>
        import dearpygui._dearpygui as internal_dpg
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/dearpygui/_dearpygui.so, 2): Library not loaded: /usr/local/opt/libpng/lib/libpng16.16.dylib
    Referenced from: /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/dearpygui/_dearpygui.so
    Reason: image not found

Standalone, minimal, complete and verifiable example

import dearpygui.dearpygui as dpg

I've attempted with the newest 1.0.2 demo (run from IDLE and terminal as noted above), but just the import statement is what fails.

I was just running DearPyGui 0.8.44 and importing it and running its demo worked.

Maybe something to note is that after updating the library (on my Python 3.9.2 from DearPyGui 0.8.44 to 1.0.2), after pip uninstalling and installing the library, or after an install/update of Python (updated Python 3.10 prerelease to 3.10.0 with the official installer), and attempting to import for the first time, it won't fail smoothly, and you will need to wait or issue a keyboard interrupt to get back to the Python shell prompt (it will reach "Reason: image not found"). Thereafter, an attempted import will fail instantly and immediately display a new line prompt (just like in the screenshot). I've reproduced this once. (I suppose this is from making the .pyc files?)

ZedOud avatar Nov 03 '21 05:11 ZedOud

Hi, would you happen to be running with the m1 chip?

hoffstadt avatar Nov 03 '21 11:11 hoffstadt

Hi, would you happen to be running with the m1 chip?

No, I am not. My specs are: MacBook Pro (16-inch, 2019) 2.4 GHz 8-Core Intel Core i9 AMD Radeon Pro 5500M

ZedOud avatar Nov 03 '21 21:11 ZedOud

macOS Big Sur 11.5.2 Version 1.0.2

I have got a similar problem on a m1 machine with the following specs: MacBook Pro (13-inch, M1, 2020) Apple M1

>>> from dearpygui.dearpygui import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/dearpygui/dearpygui.py", line 22, in <module>
    import dearpygui._dearpygui as internal_dpg
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/dearpygui/_dearpygui.so, 2): Library not loaded: /usr/local/opt/libpng/lib/libpng16.16.dylib
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/dearpygui/_dearpygui.so
  Reason: image not found

micfong-z avatar Nov 04 '21 00:11 micfong-z

Planning a fix for next release.

hoffstadt avatar Nov 05 '21 13:11 hoffstadt

@ZedOud and @0Micfong0 how are you installing python under MacOS. I don't have any issues (I only have an intel Mac) however I am using python installed via Homebrew. Looks like you may be using the MacOS system python. That might fix the issue for you.

west-rynes avatar Nov 07 '21 13:11 west-rynes

@ZedOud and @0Micfong0 how are you installing python under MacOS. I don't have any issues (I only have an intel Mac) however I am using python installed via Homebrew. Looks like you may be using the MacOS system python. That might fix the issue for you.

I am using the installers provided at python.org

ZedOud avatar Nov 09 '21 01:11 ZedOud

I had the same error running from a M1 Macbook Air. I copied the missing /usr/local/opt/libpng/lib/libpng16.16.dylib and got the following traceback.

Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/Users/douglaslassance/Desktop/WIP/deargui/main.py", line 1, in <module>
    import dearpygui.dearpygui as dpg
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/dearpygui/dearpygui.py", line 22, in <module>
    import dearpygui._dearpygui as internal_dpg
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/dearpygui/_dearpygui.so, 2): Library not loaded: /usr/local/opt/libpng/lib/libpng16.16.dylib
  Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/dearpygui/_dearpygui.so
  Reason: no suitable image found.  Did find:
	/usr/local/opt/libpng/lib/libpng16.16.dylib: mach-o, but wrong architecture
	/usr/local/opt/libpng/lib/libpng16.16.dylib: mach-o, but wrong architecture

douglaslassance avatar Nov 10 '21 10:11 douglaslassance

Is this issue still present in 1.1?

hoffstadt avatar Nov 18 '21 01:11 hoffstadt

Is this issue still present in 1.1?

Yes. And the error is identical.

Also, if it matters, at least this much works for me in 1.0.2 and 1.1

import dearpygui
dearpygui.__version__
'1.1'

ZedOud avatar Nov 18 '21 04:11 ZedOud

@0Micfong0 M1 is not really supported yet because none of the CI providers we have found have m1 runners. The alternative is for us to build them locally (like we do for the raspberry pi) but we don't personally have an M1 yet. You could also try building from source following the wiki but we obviously haven't tested with m1s.

@ZedOud Still haven't figured out your issue yet. We've tested on 3 macs we have laying around and @kuchi's Mac seems to be working. I will have to do a bit more research.

hoffstadt avatar Nov 18 '21 13:11 hoffstadt

@hoffstadt I found a solution: https://stackoverflow.com/questions/45098434/module-build-failed-error-dyld-library-not-loaded-usr-local-opt-libpng-lib

brew install libpng

This came after deleting my Python 3.9 and 3.10 installations from /Library/Frameworks/Python.framework and from Applications. At that point, I was left with the Python 3.9 installed by Homebrew.

Running brew doctor I ignored the "Unbrewed static libraries..." Warnings (much of it was Vulkan related). I followed its prompting to run brew cleanup (cleaning the 3.9 and 3.10 python.org installer leftovers) then brew link [email protected]. This may or may not be relevant.

Next I did pip3 install dearpygui and tested import dearpygui.dearpygui as dpg in brew's python3.9 and still received the same error reported originally.

After some googling, I found the above stackoverflow post and attempted brew install libpng and then ran the standard dpg demo and it worked.

ZedOud avatar Nov 23 '21 04:11 ZedOud

That’s great that worked. I have so many libraries installed I probably have always had libpng installed. I wonder if I would have run into the issue if I didn’t. Such a pain to figure these things out. I wonder if libpng should be included in the mac wheel.

west-rynes avatar Nov 23 '21 15:11 west-rynes

I'll have to check if we are actually utilizing libpng. I know its an optional dependency of freetype but we might not be using it.

hoffstadt avatar Nov 23 '21 20:11 hoffstadt

FWIW I'm running the following: MacBook Pro 14" M1 Pro Chip And seeing the same error with the most recent update.

tychaney avatar Dec 02 '21 01:12 tychaney

@hoffstadt I found a solution: https://stackoverflow.com/questions/45098434/module-build-failed-error-dyld-library-not-loaded-usr-local-opt-libpng-lib

brew install libpng

This came after deleting my Python 3.9 and 3.10 installations from /Library/Frameworks/Python.framework and from Applications. At that point, I was left with the Python 3.9 installed by Homebrew.

Running brew doctor I ignored the "Unbrewed static libraries..." Warnings (much of it was Vulkan related). I followed its prompting to run brew cleanup (cleaning the 3.9 and 3.10 python.org installer leftovers) then brew link [email protected]. This may or may not be relevant.

Next I did pip3 install dearpygui and tested import dearpygui.dearpygui as dpg in brew's python3.9 and still received the same error reported originally.

After some googling, I found the above stackoverflow post and attempted brew install libpng and then ran the standard dpg demo and it worked.

This issues is still around, but the brew install libpng worked for me.

2020 MacBook Pro 13" Intel

is-PARKER avatar Jan 28 '22 03:01 is-PARKER

I also am seeing this issue on new systems I was installing DPG without libpng pre installed with brew. @hoffstadt it would be great if libpng would be included with the DPG wheel if it is needed or removed as a needed dependency if it is not needed. It can also cause issues / failures if trying to package an app depending on the tooling someone uses currently. This appears to be an issue on Intel & M1 MacOS builds.

west-rynes avatar Jun 24 '22 11:06 west-rynes

This should be fixed. Can we confirm?

hoffstadt avatar Sep 24 '22 04:09 hoffstadt