imagepaste icon indicating copy to clipboard operation
imagepaste copied to clipboard

[Bug] ImportError: DLL load failed: %1 is not a valid Win32 application.

Open Kristinita opened this issue 8 years ago • 4 comments

1. Summary

I can not begin to use ImagePaste, I get stack trace.

2. Expected behavior

Successful begin to use ImagePaste.

3. Actual behavior

Traceback (most recent call last):
  File "D:\Sublime Text 3 x64\Data\Packages\ImagePaste\ImagePaste.py", line 5, in <module>
    from PIL import ImageGrab
  File "D:\Sublime Text 3 x64\Data\Packages\ImagePaste\PIL\ImageGrab.py", line 18, in <module>
    from PIL import Image
  File "D:\Sublime Text 3 x64\Data\Packages\ImagePaste\PIL\Image.py", line 66, in <module>
    from PIL import _imaging as core
ImportError: DLL load failed: %1 is not a valid Win32 application.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\Sublime Text 3 x64\sublime_plugin.py", line 109, in reload_plugin
    m = importlib.import_module(modulename)
  File "./python3.3/importlib/__init__.py", line 90, in import_module
  File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 584, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1022, in load_module
  File "<frozen importlib._bootstrap>", line 1003, in load_module
  File "<frozen importlib._bootstrap>", line 560, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 868, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "D:\Sublime Text 3 x64\Data\Packages\ImagePaste\ImagePaste.py", line 10, in <module>
    from PIL import ImageGrab
  File "D:\Sublime Text 3 x64\Data\Packages\ImagePaste\PIL\ImageGrab.py", line 18, in <module>
    from PIL import Image
  File "D:\Sublime Text 3 x64\Data\Packages\ImagePaste\PIL\Image.py", line 66, in <module>
    from PIL import _imaging as core
ImportError: DLL load failed: %1 is not a valid Win32 application.

4. Steps to reproduce

I reproduce the problem in a version of Sublime Text without plugins and user settings.

I install ImagePaste → I get stack trace in console → I restart Sublime Text → image_paste command don't work for me.

5. Environment

Operating system and version: Windows 10 Enterprise LTSB 64-bit EN Sublime Text: Build 3126 ImagePaste: v1.0.3

Thanks.

Kristinita avatar Feb 20 '17 16:02 Kristinita

Could you try below test using your system python, for I am using win7, I do not have win10 environment to test.

  1. Install PIL lib for your system python
pip install pillow
  1. save below as test.py
try:
    from PIL import ImageGrab
    from PIL import ImageFile
except ImportError:
    import sys
    from PIL import ImageGrab
    from PIL import ImageFile

ImageFile.LOAD_TRUNCATED_IMAGES = True
im = ImageGrab.grabclipboard()
im.save('pic.png','PNG')
  1. Take a screenshot and save to clipboard, then try below command
python .\test.py

Thanks!

robinchenyu avatar Feb 21 '17 14:02 robinchenyu

@robinchenyu ,

PS D:\Test> python .\test.py
Traceback (most recent call last):
  File ".\test.py", line 11, in <module>
    im.save('pic.png', 'PNG')
AttributeError: 'NoneType' object has no attribute 'save'

Thanks.

Kristinita avatar Mar 14 '17 15:03 Kristinita

The error maybe clipboard is empty, pls take screenshot before run test.py

robinchenyu avatar Mar 15 '17 06:03 robinchenyu

我也遇到了同样的问题。

firezheng avatar Dec 04 '18 08:12 firezheng