Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8015

Python • Re: Why does importing 'Crypto' not work, but importing 'Cryptodome' does?

$
0
0
If the solution really is to use --break-system-packages then that's what I'll do.
That is one approach but the recommended method starting in Bookworm is to create a virtual environment (VENV). See https://docs.python.org/3/library/venv.html and https://realpython.com/python-virtual-e ... -a-primer/. This is what I'm currently using but I also ensure it is set up to use system level installs by setting --system-site-packages.

Here's an example for your environment. Note you have to SOURCE each time you want to work in the VENV.

Code:

pi@wethCAM:/media $ python -m venv --system-site-packages my-venvpi@wethCAM:/media $ source my-venv/bin/activate(my-venv) pi@wethCAM:/media $ # from https://pypi.org/project/pycryptodome/(my-venv) pi@wethCAM:/media $ (my-venv) pi@wethCAM:/media $ pip install pycryptodomeLooking in indexes: https://pypi.org/simple, https://www.piwheels.org/simpleCollecting pycryptodome  Downloading pycryptodome-3.23.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.2 MB)     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.2/2.2 MB 1.5 MB/s eta 0:00:00Installing collected packages: pycryptodomeSuccessfully installed pycryptodome-3.23.0(my-venv) pi@wethCAM:/media $ pythonPython 3.11.2 (main, Apr 28 2025, 14:11:48) [GCC 12.2.0] on linuxType "help", "copyright", "credits" or "license" for more information.>>> from Crypto.Cipher import AES>>> exit()(my-venv) pi@wethCAM:/media $ deactivatepi@wethCAM:/media $ 

Statistics: Posted by DS256 — Wed Sep 10, 2025 8:41 pm



Viewing all articles
Browse latest Browse all 8015

Trending Articles