Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excellent tutorial for Cython+PyInstaller, But more help needed. #2

Open
gaamaaresosa opened this issue Apr 18, 2023 · 4 comments
Open

Comments

@gaamaaresosa
Copy link

gaamaaresosa commented Apr 18, 2023

@mobiusklein First of all thank you so much for your effort.
While I was searching similar concept, luckily I got this post.
Though you had taken good efforts to explain the steps, its bit hard to understand
as some more steps missing in between.

Btw, will the output binarry is still Bytecode or native machine language binary.
I am interested the main code should be native machine language binary.
And may be the PyInstaller loader binary could be any.

Kindly correct me where I am wrong.
In future if you have time, please make better tutorial on this same topic.
Or refer me similar topic is some one already done.

I tried my best to fill that steps and no success yet.

  1. No proper command line to execute setup.py
    I used below command, see the error and confused.
    And expected "app.c", "app.so", "calc.c" and "calc.so" files inside my_package folder
    But only "app.c", "calc.c" produced.
    Where are the "app.so" and "calc.so" files.
    Or this is what expected ?
BAD CALL: $ sudo python3 ./setup.py
GOOD CALL:  $ sudo python3 setup.py build_ext --inplace
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: no commands supplied
  1. What next ?
    I trying runing build.sh from pyinstaller folder.
$ sudo ./build.sh
Beginning build
493 INFO: PyInstaller: 5.10.1
494 INFO: Python: 3.7.3
497 INFO: Platform: Linux-6.1.23-v8+-aarch64-with-debian-10.13
498 INFO: wrote /home/pi/Cython_PyInstaller_Test/pyinstaller/my_mandelbrot.spec
509 INFO: UPX is available.
512 INFO: Extending PYTHONPATH with paths
... more lines...

68101 INFO: Building COLLECT COLLECT-00.toc
71575 INFO: Building COLLECT COLLECT-00.toc completed successfully.
  1. Now I could see the executable "my_mandelbrot", 100s of files and some folders at
    /home/pi/Cython_PyInstaller_Test/pyinstaller/dist/my_mandelbrot

After running that binary I get below error.
Lost interest...
May be main reason is extra new bundles (numpy, matplotlib )

Of course I have installed numpy, matplotlib, PyInstaller and Cython
I have followed the directory tree as you had suggested.

Path

 $ sudo ./my_mandelbrot
Traceback (most recent call last):
  File "my_mandelbrot.py", line 6, in <module>
ModuleNotFoundError: No module named 'my_package'
[26831] Failed to execute script 'my_mandelbrot' due to unhandled exception!

System:
Raspberry Pi 4
Linux buster 32bit OS

Note:
Kindly avoid using extra packages while explaing a new concept with simple project.
Here numpy, matplotlib could have been avoided as the numpy hangs for 30mins to install.
I got diverted from the understanding thread.

A big thanks again !

@gaamaaresosa
Copy link
Author

gaamaaresosa commented Apr 19, 2023

After few hours of experiment I made this code to work.

  1. sudo python3 setup.py build_ext --inplace (NOT sudo python3 setup.py)
    app.cpython-37m-arm-linux-gnueabihf.so
    calc.cpython-37m-arm-linux-gnueabihf.so
    These 2 .so files I got it as expected.

  2. I have to move "my_package" folder to
    /home/pi/.gstreama/Cython_PyInstaller_Test/pyinstaller/dist/my_mandelbrot/

If the expert authors spend another few seconds and write proper lines
People like me with half knowledge on linux could see success.

Thanks to this author again !

@mobiusklein
Copy link
Owner

@gaamaaresosa I've modified the README to include details about how to invoke the setup.py script. Do those steps work when you try to build the executable?

@gaamaaresosa
Copy link
Author

@gaamaaresosa I've modified the README to include details about how to invoke the setup.py script. Do those steps work when you try to build the executable?

Thank you so much again.
I will test it.

@gaamaaresosa
Copy link
Author

gaamaaresosa commented Apr 21, 2023

I tried several times and no success yet.
Main reason I doubt is extra matplotlib installation.
The error showing on that one.

Its a very good topic. But hard to undersatnd the nested logic.
If any one do better tutorial without installing extra packages like numpy and matplotlib.
That could easily be followed. Experts may not need these tutorials because they are experts.
But always think of us.

Any how let me try to understand it...

numpy installation hangs for ever:
I tried 3 times and no success. No more patients...

image

11631 INFO: Appending PKG archive to custom ELF section in EXE
11645 INFO: Building EXE from EXE-00.toc completed successfully.
11648 INFO: checking COLLECT
11648 INFO: Building COLLECT because COLLECT-00.toc is non existent
11648 INFO: Building COLLECT COLLECT-00.toc
12074 INFO: Building COLLECT COLLECT-00.toc completed successfully.
raspberry@pi:~/.raspberry/Cython_PyInstaller_Test/pyinstaller $ cd /home/raspberry/.raspberry/Cython_PyInstaller_Test/pyins        taller/dist/my_mandelbrot
raspberry@pi:~/.raspberry/Cython_PyInstaller_Test/pyinstaller/dist/my_mandelbrot $ sudo my_mandelbrot
sudo: my_mandelbrot: command not found
raspberry@pi:~/.raspberry/Cython_PyInstaller_Test/pyinstaller/dist/my_mandelbrot $ sudo ./my_mandelbrot
Traceback (most recent call last):
  File "my_mandelbrot.py", line 2, in <module>
ModuleNotFoundError: No module named 'matplotlib'
[20539] Failed to execute script 'my_mandelbrot' due to unhandled exception!
raspberry@pi:~/.raspberry/Cython_PyInstaller_Test/pyinstaller/dist/my_mandelbrot $```

After installing success also I see same error.

```  Created wheel for numpy: filename=numpy-1.21.6-cp37-cp37m-linux_aarch64.whl size=14967401 sha256=e827f6c9839449e28d553f7060b95e9c42ef03d6d80a2824be69a4390334479a
  Stored in directory: /root/.cache/pip/wheels/4e/7e/9e/0fde042ccff2493994076dac9c3fbd78feb444c3bd94eb386a
Successfully built numpy
Installing collected packages: python-dateutil, packaging, numpy, kiwisolver, fonttools, cycler, matplotlib
  Attempting uninstall: numpy
    Found existing installation: numpy 1.16.2
    Uninstalling numpy-1.16.2:
      Successfully uninstalled numpy-1.16.2
Successfully installed cycler-0.11.0 fonttools-4.38.0 kiwisolver-1.4.4 matplotlib-3.5.3 numpy-1.21.6 packaging-23.1 python-dateutil-2.8.2
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
raspberry@pi:~/.raspberry/Cython_PyInstaller_Test/pyinstaller/dist/my_mandelbrot $ sudo ./my_mandelbrot
Traceback (most recent call last):
  File "my_mandelbrot.py", line 2, in <module>
ModuleNotFoundError: No module named 'matplotlib'
[21671] Failed to execute script 'my_mandelbrot' due to unhandled exception!
raspberry@pi:~/.raspberry/Cython_PyInstaller_Test/pyinstaller/dist/my_mandelbrot $```


NOTE:
LINUX OS IS NOT STABLE LIKE WINDOWS
ON EVERY UPDATE SOMETHING OR OTHER WILL NOT WORK.
TODAY IF YOU MAKE SOME TUTORIAL NEXT YEAR IT WILL THROW ERRORS.
SO NO EXTRA PACKAGES TO EXPLAIN SOME IMPORTANT TOPIC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants