0

My problem is that i can't import numpy into my processing.py project. When I try to import it i get the error "No module named numpy". What can I do?

martineau
  • 119,623
  • 25
  • 170
  • 301
Hurjui Ionut
  • 357
  • 1
  • 2
  • 7
  • Python 2 or Python 3? Make sure numpy is installed for whatever Python you are using (2 or 3). – karel May 08 '19 at 12:23
  • have you installed numpy? `pip install numpy` – Carlos Gonzalez May 08 '19 at 12:23
  • Have you installed the package in your virtual envronment(if using one) or your system through pip? – Trollsors May 08 '19 at 12:24
  • As @CarlosGonzalez said, go to cmd (Windows) or your Terminal (Linux) and type in ````pip install numpy```` – Trollsors May 08 '19 at 12:26
  • @Trollsors still dosen't work. – Hurjui Ionut May 08 '19 at 12:28
  • @HurjuiIonut Do you have pip installed on your computer ? Which version of Python are you using and on what OS ? Did you get any error messages installing numpy (if so what where they) ? – George Profenza May 08 '19 at 12:29
  • 1
    It's just impossible to help you with this few details. Just check [numpy's getting started](https://www.numpy.org/#getting-started) – Right leg May 08 '19 at 12:30
  • @GeorgeProfenza Yes i have pip installed. I'M useing Python 3.7.3 on a windows 10, no I didn't get any error when i've installed numpy – Hurjui Ionut May 08 '19 at 12:32
  • does this command print a version number ? `python -c 'import numpy;print(numpy.__version__)'` Do other pip installed modules work ? Maybe the path where pip installs modules insn't appended to the `PYTHONPATH` environment variable ? (I'd also try a system reboot just tick that off the list :) ) – George Profenza May 08 '19 at 12:35
  • @HurjuiIonut are you using anaconda? check bumpy is installed in your current envir – Shijith May 08 '19 at 12:36
  • @Shijith No, but I had it at a moment in my pc... – Hurjui Ionut May 08 '19 at 12:41
  • @GeorgeProfenza the good old reboot didnt solve the problem :( that command dindn't outputted a version number indeed – Hurjui Ionut May 08 '19 at 12:42
  • If the pip install worked with no issues my hunch is Python doesn't know where pip modules are installed. Try to find the `Scripts` folder where pip installed numpy and add that your the `PATH` environment variable and run a new command prompt with the Python interpreter to test. If that didn't work, but numpy is on your system I can think of a hacky test: 1. run a python interpreter from where numpy is installed: `import numpy` should work just in that folder. 2. make a symbolic link (see `mklink` command) from the path where pip installs modules to the default python install `Scripts` ... – George Profenza May 08 '19 at 13:40
  • 1
    @HurjuiIonut After seeing John Coleman's answer I realise you meant the Processing Python mode, which indeed uses Jython. If it's only rendering you need with using Processing like functions in Python consider trying [pyprocessing](https://github.com/esperanc/pyprocessing) or [p5.py](https://pypi.org/project/p5/) at this point in time. – George Profenza May 08 '19 at 14:39
  • @GeorgeProfenza thanks a lot anyway! – Hurjui Ionut May 08 '19 at 15:02

1 Answers1

5

Processing is built on top of the JVM so the Python mode of Processing uses Jython rather than CPython. Unfortunately, numpy doesn't support Jython. Thus, you are trying to do something which is impossible. From the SciPy FAQ:

Q: Does NumpPy/SciPy work with Jython or C#/.Net?

A: No, neither are supported. Jython never worked, because it runs on top of the Java Virtual Machine and has no way to interface with extensions written in C for the standard Python (CPython) interpreter."

This question discusses some alternatives to numpy which can be used from Jython. The official Jython FAQ recommends JNumeric.

John Coleman
  • 51,337
  • 7
  • 54
  • 119