Does anyone know how to install the numpy library in Thonny? I'm getting this error:
Installing to temp directory
Error installing 'numpy==1.19.5': , packages may be partially installed
Installing to: /var/folders/43/v1d780lj3dvff3z8g6t_qphr0000gn/T/tmpl3d3osg2/
Warning: pypi.org SSL certificate is not validated
micropip returned with error code 1
Re: numpy
Hi rwcooper
I'm running Thonny (which I am totally new to) on a MacBook, and I was using the Tools/Manage Packages or Manage Plug-ins to load the libraries. It seems to find the relevant package and even shows it as now installed in Manage Plug-ins which doesn't seem to be relevant for creating MicroPython for the Pico. I just realised it's the Manage Packages I need for the MicroPython and that's where I am getting that certificate error. Stopping Thonny and restarting it after the download as recommended doesn't allow my MicroPython code to load numpy. The same also applies to another library - matplotlib.pylab which also gets the certificate error. As I said, I'm new to using Thonny. I also have an RPi400 which I could use for programming the Pico, so I"m sure I could then use the apt-install commands.
If anyone knows how to do it on a Mac, that is currently my preferred option.
Tony
I'm running Thonny (which I am totally new to) on a MacBook, and I was using the Tools/Manage Packages or Manage Plug-ins to load the libraries. It seems to find the relevant package and even shows it as now installed in Manage Plug-ins which doesn't seem to be relevant for creating MicroPython for the Pico. I just realised it's the Manage Packages I need for the MicroPython and that's where I am getting that certificate error. Stopping Thonny and restarting it after the download as recommended doesn't allow my MicroPython code to load numpy. The same also applies to another library - matplotlib.pylab which also gets the certificate error. As I said, I'm new to using Thonny. I also have an RPi400 which I could use for programming the Pico, so I"m sure I could then use the apt-install commands.
If anyone knows how to do it on a Mac, that is currently my preferred option.
Tony
Re: numpy
A google search suggested using "pip install certifi" at the terminal to install the required SSL certificate package, but that didn't work either.
I also typed pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org numpy -vvv. That installed numpy for the Mac, but not where Thonny could pick it up for programming the Pico. The trouble is I don't understand the structure of all this, so I am typing in the dark.
Tony
I also typed pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org numpy -vvv. That installed numpy for the Mac, but not where Thonny could pick it up for programming the Pico. The trouble is I don't understand the structure of all this, so I am typing in the dark.
Tony
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 339
- Joined: Fri Apr 12, 2019 11:00 am
- Location: austin tx
Re: numpy
Someone was asking how to add a native C implemented python module to the RP2040 version of MicroPython, so I started this branch
https://github.com/raspberrypi/micropyt ... ed0a95a258
The example I used (in the comments) ulab I believe include numpy
So if you're feeling adventurous you can build that!
https://github.com/raspberrypi/micropyt ... ed0a95a258
The example I used (in the comments) ulab I believe include numpy
So if you're feeling adventurous you can build that!
Re: numpy
Hi Kilograham
I had a look at your github link, but AKAIK that doesn’t help a beginner wanting to use the ‘approved’ Thonny on a Mac. I think the problem is to do with the latest Mac OS not having some SSL certificate support. If I could get the ‘trusted site’ command into Thonny’s output, I believe I could make it work.
I had a look at your github link, but AKAIK that doesn’t help a beginner wanting to use the ‘approved’ Thonny on a Mac. I think the problem is to do with the latest Mac OS not having some SSL certificate support. If I could get the ‘trusted site’ command into Thonny’s output, I believe I could make it work.
Re: numpy
I’ve found some helpful info here which says that it’s not the SSL certificate that’s a problem, but attempting to load C/C++ packages, not MicroPython. Not sure about this, but will continue investigating.
https://github.com/thonny/thonny/issues/1330
https://github.com/thonny/thonny/issues/1330
Re: numpy
The package system for MicroPython is quite different to the package system for Python, especially when it comes to C extension packagess. Using "pip" to install a Python package isn't enough to make that available for MicroPython.
I expect this 'MicroPython isn't Python' is going to catch a few people out and especially when it comes to packages.
Re: numpy
OK - answer found - numpy can't be installed on MicroPython devices:
https://github.com/thonny/thonny/issues ... -766325151
https://github.com/thonny/thonny/issues ... -766325151
Re: numpy
numpy can't — it's meant for real computers with actual memory — but ulab can. It may need to be compiled into the MicroPython image, and it might be too big for the Raspberry Pi Pico anyway, but it provides a numpy-like vector maths interface.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him
Pronouns: he/him
Re: numpy
Hi scruss
Thanks for that. Perhaps someone with more knowledge than me will port https://github.com/v923z/micropython-ulab to the Pico.
Tony
Thanks for that. Perhaps someone with more knowledge than me will port https://github.com/v923z/micropython-ulab to the Pico.
Tony
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 339
- Joined: Fri Apr 12, 2019 11:00 am
- Location: austin tx
Re: numpy
That was what I was referring to abovenumpy can't — it's meant for real computers with actual memory — but ulab can. It may need to be compiled into the MicroPython image, and it might be too big for the Raspberry Pi Pico anyway, but it provides a numpy-like vector maths interface.
Basically the commit message suggests how to build ulab into the RP2040 version of micropython (which was what I tried) - it seemed happy enough with the two line test program I tried!kilograham wrote: ↑Sun Jan 24, 2021 12:25 amSomeone was asking how to add a native C implemented python module to the RP2040 version of MicroPython, so I started this branch
https://github.com/raspberrypi/micropyt ... ed0a95a258
The example I used (in the comments) ulab I believe include numpy
So if you're feeling adventurous you can build that!
Re: numpy
Hi all,
A friend of mine brought this discussion to my attention. I am the maintainer of ulab, and just wanted to point out that, if you need hooks, or middleware in ulab itself, I am more than happy to add that. I have accommodated similar requests from circuitpython and openmv in the past, and on those platforms, ulab is a one-stop solution: they simply link to my repository, and automatically compile from that code. Just let me know, if you need anything like that.
A friend of mine brought this discussion to my attention. I am the maintainer of ulab, and just wanted to point out that, if you need hooks, or middleware in ulab itself, I am more than happy to add that. I have accommodated similar requests from circuitpython and openmv in the past, and on those platforms, ulab is a one-stop solution: they simply link to my repository, and automatically compile from that code. Just let me know, if you need anything like that.
Re: numpy
`ulab` is enabled in the CircuitPython build for the Pico available here: https://circuitpython.org/board/raspberry_pi_pico/
CircuitPython getting started instructions are here: https://learn.adafruit.com/getting-star ... cuitpython
Basic API examples are here: https://learn.adafruit.com/circuitpython-essentials/
CircuitPython getting started instructions are here: https://learn.adafruit.com/getting-star ... cuitpython
Basic API examples are here: https://learn.adafruit.com/circuitpython-essentials/