starfive-tech / VisionFive2

438 stars 78 forks source link

Python3 module not found: 'zlib' #68

Open PPPPierre opened 11 months ago

PPPPierre commented 11 months ago

I first found this problem when I compiled a image for my project where need 'requests' module for python. I chose python-requests in make buildroot_rootfs-menuconfig then compile the image based on the steps shown in readme. Finally I entered the system but I failed in running python import requests. It returned an error as followed:

>>>import requests Traceback (most recent call last): File "", line 1, in File "/usr/lib/python3.9/site-packages/requests/init.py", line 43, in File "/usr/lib/python3.9/site-packages/urllib3/init.py", line 13, in File "/usr/lib/python3.9/site-packages/urllib3/connectionpool.py", line 40, in File "/usr/lib/python3.9/site-packages/urllib3/response.py", line 5, in ModuleNotFoundError: No module named 'zlib'

Then I tried to import directly zlib, it gave me this:

>>>import zlib Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'zlib'

The same problem is found with tagv3.1.5 The information about this problem is very rare on the internet, the closest one that I found is this. It seems the cross-compile tool-chain didnt well compiled libz during the compilation.

Can you fix this problem, thx !

andyhu-stf commented 11 months ago

Hi PPPierre, please select BR2_PACKAGE_PYTHON_REQUESTS and BR2_PACKAGE_PYTHON3_ZLIB through make buildroot_initramfs-menuconfig or make buildroot_rootfs-menuconfig, then build SDK again. It work well on my board.

if you do not want to build the work/ again, you can try: e.g. for buildroot_initramfs:

make -C ./work/buildroot_initramfs/ O=./work/buildroot_initramfs python3-dirclean  # (For BR2_PACKAGE_PYTHON3_ZLIB is in python3)
rm work/buildroot_initramfs/images/rootfs.tar
make -jx