how do you install numpy in venv?
Pi Zero W, Python 3, Bookworm
In theory it should be trivial:
But it doesn't work. Instead of downloading ready code my pi tries to compile everything, it takes days (not sure how long actually, after 24h I had to leave for three days), and eventually it fails:
(earlier it was failing with a message about missing OpenSSL development package, but I installed the package and it gets past that step).
Installing global version of numpy with "sudo apt install python3-numpy" works nicely, but is of no use in venv.
Any ideas/suggestions?
In theory it should be trivial:
Code: Select all
python3 -m venv ws
source ~/ws/bin/activate
pip install numpy
Code: Select all
Installing backend dependencies: still running...
Installing backend dependencies: still running...
Installing backend dependencies: finished with status 'done'
Preparing metadata (pyproject.toml): started
Preparing metadata (pyproject.toml): finished with status 'done'
Collecting ninja>=1.8.2
Using cached https://www.piwheels.org/simple/ninja/ninja-1.11.1.4-py3-none-linux_armv6l.whl (134 kB)
Building wheels for collected packages: patchelf
Building wheel for patchelf (pyproject.toml): started
Building wheel for patchelf (pyproject.toml): finished with status 'error'
error: subprocess-exited-with-error
×ばつ Building wheel for patchelf (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [29 lines of output]
*** scikit-build-core 0.11.5 using CMake 4.0.3 (wheel)
*** Configuring CMake...
loading initial cache file build/py3-none-linux_armv6l/CMakeInit.txt
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/arm-linux-gnueabihf-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/arm-linux-gnueabihf-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (9.5s)
-- Generating done (0.1s)
-- Build files have been written to: /tmp/pip-install-b61tw2r9/patchelf_441f840ce8c346368ac9be1b8c3c43a5/build/py3-none-linux_armv6l
*** Building project with Unix Makefiles...
[ 11%] Creating directories for 'build_patchelf'
[ 22%] No download step for 'build_patchelf'
[ 33%] No update step for 'build_patchelf'
[ 44%] Performing patch step for 'build_patchelf'
./bootstrap.sh: 2: autoreconf: not found
gmake[2]: *** [CMakeFiles/build_patchelf.dir/build.make:114: build_patchelf-prefix/src/build_patchelf-stamp/build_patchelf-patch] Error 127
gmake[1]: *** [CMakeFiles/Makefile2:90: CMakeFiles/build_patchelf.dir/all] Error 2
gmake: *** [Makefile:136: all] Error 2
*** CMake build failed
[end of output]Installing global version of numpy with "sudo apt install python3-numpy" works nicely, but is of no use in venv.
Any ideas/suggestions?
Re: how do you install numpy in venv?
Why not? Did you create the venv with --system-site-packages ?
Unreadable squiggle
Re: how do you install numpy in venv?
It wasn't your substantive question, but why is the apt-installed version of python3-numpy of no use?
There is Raspberry Pi Documentation here - Install Python packages using apt - https://www.raspberrypi.com/documentati ... -using-apt
You may need to take account of the Tip highlighted later on -
Tip
Pass the --system-site-packages flag before the folder name to preload all of the currently installed packages in your system Python installation into the virtual environment.
{Edit: yes, same response discovered after typing it in... Left for emphasis.}
Beware of the Leopard
Re: how do you install numpy in venv?
I don't know if it's relevant here but note this about numpy versions...
viewtopic.php?t=390865#p2331659
I believe raspios comes with numpy installed
viewtopic.php?t=390865#p2331659
I believe raspios comes with numpy installed
Re: how do you install numpy in venv?
Thanks guys, --system-site-packages helped.
In my defense most pages I visited before asking here warned against installing packages globally and suggested to use pip only, so I didn't even try to dig deeper in that direction (and venv is not something I am familiar with). Apparently as usual good practices say one thing, and reality says screw good practices.
In my defense most pages I visited before asking here warned against installing packages globally and suggested to use pip only, so I didn't even try to dig deeper in that direction (and venv is not something I am familiar with). Apparently as usual good practices say one thing, and reality says screw good practices.
- robertojguerra
- Posts: 114
- Joined: Thu Dec 05, 2024 6:35 pm
Re: how do you install numpy in venv?
Inside a venv, pip will compile numpy from source because the pip website does not host the 32 bit arm version.
You can make your own pip wheel for 32 bit numpy, back it up, and then install it in every venv you want to use it.
You can make your own pip wheel for 32 bit numpy, back it up, and then install it in every venv you want to use it.
Re: how do you install numpy in venv?
Have you tried that on a Pi02 (see OP)?robertojguerra wrote: ↑Thu Nov 13, 2025 10:29 pmInside a venv, pip will compile numpy from source because the pip website does not host the 32 bit arm version.
You can make your own pip wheel for 32 bit numpy, back it up, and then install it in every venv you want to use it.
- robertojguerra
- Posts: 114
- Joined: Thu Dec 05, 2024 6:35 pm
Re: how do you install numpy in venv?
No, but I compiled opencv with non-standard options (Wayland) and installed it via pip in a venv, without contaminating the operating system, in a 64 bit arm.
I think it would help you in your 32 bit problem, if you are able to download and compile numpy, but stop before "sudo make install" and instead make a pip wheel package.
Update:
I used this guide to create my opencv wheel
https://medium.com/@sachinsoni600517/op ... b0b7d00c11
adapt the instructions to create your numpy wheel for 32 bits
I think it would help you in your 32 bit problem, if you are able to download and compile numpy, but stop before "sudo make install" and instead make a pip wheel package.
Update:
I used this guide to create my opencv wheel
https://medium.com/@sachinsoni600517/op ... b0b7d00c11
adapt the instructions to create your numpy wheel for 32 bits
Jump to
- Community
- General discussion
- Announcements
- Other languages
- Deutsch
- Español
- Français
- Italiano
- Nederlands
- 日本語
- Polski
- Português
- Русский
- Türkçe
- User groups and events
- Raspberry Pi Official Magazine
- Using the Raspberry Pi
- Beginners
- Troubleshooting
- Advanced users
- Assistive technology and accessibility
- Education
- Picademy
- Teaching and learning resources
- Staffroom, classroom and projects
- Astro Pi
- Mathematica
- High Altitude Balloon
- Weather station
- Programming
- C/C++
- Java
- Python
- Scratch
- Other programming languages
- Windows 10 for IoT
- Wolfram Language
- Bare metal, Assembly language
- Graphics programming
- OpenGLES
- OpenVG
- OpenMAX
- General programming discussion
- Projects
- Networking and servers
- Automation, sensing and robotics
- Graphics, sound and multimedia
- Other projects
- Media centres
- Gaming
- AIY Projects
- Hardware and peripherals
- Camera board
- Compute Module
- Official Display
- HATs and other add-ons
- Device Tree
- Interfacing (DSI, CSI, I2C, etc.)
- Keyboard computers (400, 500, 500+)
- Raspberry Pi Pico
- General
- SDK
- MicroPython
- Other RP2040 boards
- Zephyr
- Rust
- AI Accelerator
- AI Camera - IMX500
- Hailo
- Software
- Raspberry Pi OS
- Raspberry Pi Connect
- Raspberry Pi Desktop for PC and Mac
- Beta testing
- Other
- Android
- Debian
- FreeBSD
- Gentoo
- Linux Kernel
- NetBSD
- openSUSE
- Plan 9
- Puppy
- Arch
- Pidora / Fedora
- RISCOS
- Ubuntu
- Ye Olde Pi Shoppe
- For sale
- Wanted
- Off topic
- Off topic discussion