yoyoberenguer / PygameShader

2D Game texture special effects
GNU General Public License v3.0
24 stars 0 forks source link

importing PygameShader when running script directly causes error: "no module named gaussianblur5x5" #1

Closed SkysurferKon closed 2 years ago

yoyoberenguer commented 2 years ago

Hi SkysurferKon,

Thank you for taking the time to report an issue.

Can you show me an example of script causing this issue ? Do you mean that an error is thrown as soon as you are importing the library ? Also if you could provide the python version used and the platform (windows ?)

It is highly recommended to use PIP for installing this library. Check your python version first to make sure you have any of this version (3.6, 3.7, 3.8, 3.9, 3.10) Then run the following command from the dos interpreter (cmd):

C:\>pip install PygameShader

If you have a different version you will see this type of error :

C:\...AppData\Local\Programs\Python\Python35\Scripts>pip install PygameShader
Collecting PygameShader
  Cache entry deserialization failed, entry ignored
  Could not find a version that satisfies the requirement PygameShader (from versions: )

No matching distribution found for PygameShader


To use the Gaussian blur you would normally import the method shader_blur5x5_array24_inplace from | blur the library such as:

In Python :

for version < 1.0.3 import PygameShader from PygameShader import shader_blur5x5_array24_inplace

for version > 1.0.3 import PygameShader from PygameShader import blur

OR

To load all the methods from the library

import PygameShader from PygameShader import *

This Error : no module named gaussianblur5x5 tells me that the cython file gaussianblur5x5 is either missing or not cynthonize (compile for your environment or python version). If you are using PIP to install PygameShader on Python version > 3.6 you would normally never see that issue as the PIP download the package with all the code already compile for your environment (PIP will detect automatically the right version and download it for you, version 3.6, 3.7, 3.8, 3.9, 3.10).

This issue can eventually happen if you are trying to build the library from the source code using C:\>python setup_shader.py build_ext --inplace

The line above will try to compile the cython code from the PYX files

yoyoberenguer commented 2 years ago

.

SkysurferKon commented 2 years ago

Thanks for writing this detailed explanation! Is PygameShader compatible with a PyInstaller "--onefile" exe file?

yoyoberenguer commented 2 years ago

Hi, If you are looking for an automatic installer, the best way to install this library is to use the well known

pip install PygameShader==1.0.4

If you are a bit more adventurous you can also download the git source code and compile the library from source

But to answer your question regarding the PyInstaller program , I would say yes, PygameShader is compatible with PyInstaller even though I never tried to use PyInstaller since this is a cython/python library that does not include any hook file but uses an external library that load with an import statement

I used PyInstaller in the past for various project including project with C & Cython & python codes and would generate an executable file. In order to create a single file you would have to tweak and configure PyInstaller to know where to find all the source code, binaries and images that needs to be attached to the executable.

yoyoberenguer commented 2 years ago

Another utility that could perform the same task would be to use the great program call Inno Setup. This will do the same and build an executable file containing all the directories and source code etc. The advantage of Inno setup is to be able to de-install the project as you would normally do for commercial programs as an optional feature