Failed to import 'numpy' module

Basic Information:

Printer Model: Creality Ender 5 Plus
MCU / Printerboard: BTT SKR 3 ez

Describe your issue:

Hey everyone, i am trying to setup and run input shaper and i am running into an issue. i have installed everything on the pi per the install page and everything seems to install corretly.

i run my senssor querry and i get values back like its working. but as soon as i try to test resoneance i get this error

i go back and do some check on the pi to see if the numpy is installed and it says its up to date and everything. i am running on python 2.7 i believe i have 3 installed on my pi as well.

numpy needs to be installed in Klipper’s “virtual environment”. Just follow the command given.

~/klippy-env/bin/pip install numpy

i input these commands per the install and i get an okay install to the pi but still get the error.
i get a message saying it is installed the most updated verison of the numpy but still same error message.

Looks like you maybe installing the python 3 libs, but using python2 for klipper. Klipper works fine under 3.X now, or you can install numpy for 2.7.

The libraries you install via the apt command are system wide and are only used if you call a script in the scripts folder, e.g.

~/klipper/scripts/calibrate_shaper.py /tmp/resonances_x_*.csv -o /tmp/shaper_calibrate_x.png

Here both variants will work. As default the “external” scripts will use Python 3.

Klipper internal commands, e.g.

SHAPER_CALIBRATE

will use their own environment. This venv is created during Klipper installation and today, by default, is still Python 2 (and only Python 2 is officially supported).

So, both are needed, depending on what you do.

Please post the output of:

~/klippy-env/bin/pip install -v numpy

Of course run / logged-in as the user under which you run Klipper.

here are my results from running all the commands





Output of the 3rd command looks a bit strange but would also indicate that numpy is installed.
Sorry, no more ideas.

A workaround would be to use the TEST_RESONANCES AXIS=... commands instead of SHAPER_CALIBRATE and use the external scripts to do the analysis. See measuring-the-resonances

one thing you can try: upgrade your system components, reinstall python2 and recreate the virtualenv ( klippy-env ):

#update sw catalog
sudo apt update

#upgrade system components
sudo apt full-upgrade -y

#reinstall python2 bin's and lib's
sudo apt install --reinstall python2* -y

#stop klipper service
sudo service klipper stop

#rename current klippy-env environment
cd ~/
mv klippy-env klippy-env.bak

#recreate klipper's virtual python2 environment
cd ~/
virtualenv -p python2 klippy-env

#switch to klipper python environment and install dependencies
cd ~/klippy-env
bin/pip install -r ../klipper/scripts/klippy-requirements.txt

#install numpy module
~/klippy-env/bin/pip install -v numpy

#start klipper service
sudo service klipper start
5 Likes

I agree, update that system first. PIP isn’t finding any of the numpy stuff for 2.7, so that’s why it’s not working. I’m hoping the update will point you at a repo that has it, and this isn’t indication of the 2.7 stuff getting pulled from PIP. If that’s the case, that python 3.x “bridge” we’ve been waiting to cross, is dead ahead.

i did the TEST_RESONANCES AXIS=x and get the error(see above images). i havent tried shaper_calibrate.

i am very bad with the programming. do i need to enter all these commands? i know i have at least python 2 and 3 installed on my pi thinking not havning pythong 3 installed since the install instrustions call for pythong 3. will this affect anything else? should i also uninstalled pythong 3?

Hmm, what about

TEST_RESONANCES AXIS=X OUTPUT=raw_data

I was under the impression that one of the commands does not need numpy and could be processed offline.

Yes. @Hundsbuah gave you an excellent step by step instruction. Just execute one by one in the order given.

1 Like

i have run this string of commands in order and i still get the same error

Before burning any more time with it, take a new SD card and start from scratch. This is really weird.

I came here having the same issue and your instructions worked for me. The end-of-life messages for python 2.7 make me wish I had found a way to make it work with python3 but working is working.

Thank you.

Hi, i have same issue. Can you explain how made u it to work? I follow instructions and still nothing
Thanks

I copy/pasted commands from Hundbuah’s post into command line one at a time. When finished I ran “TEST_RESONANCES AXIS=X” from the fluidd command line and I no longer received the numpy error.

did the making python2 env work for you? I can only do a python3 env

Thank you so much for this solution! I was having two issues, “subprocess-exited-with-error” and “error: metadata-generation-failed” after running the numpy install with Python3 and after running your command instructions all is good!