Inkscape.org
Beyond the Basics Python script numpy problem
  1. #1
    jsampson45 jsampson45 @jsampson45

    I tried to run a simple Python script and got the error message:

    "

    Traceback (most recent call last):
      File "c:\users\jrsid\appdata\local\programs\python\python311\lib\site-packages\numpy\_core\__init__.py", line 23, in <module>
        from . import multiarray
      File "c:\users\jrsid\appdata\local\programs\python\python311\lib\site-packages\numpy\_core\multiarray.py", line 10, in <module>
        from . import overrides
      File "c:\users\jrsid\appdata\local\programs\python\python311\lib\site-packages\numpy\_core\overrides.py", line 7, in <module>
        from numpy._core._multiarray_umath import (
    ModuleNotFoundError: No module named 'numpy._core._multiarray_umath'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "c:\users\jrsid\appdata\local\programs\python\python311\lib\site-packages\numpy\__init__.py", line 127, in <module>
        from numpy.__config__ import show_config
      File "c:\users\jrsid\appdata\local\programs\python\python311\lib\site-packages\numpy\__config__.py", line 4, in <module>
        from numpy._core._multiarray_umath import (
      File "c:\users\jrsid\appdata\local\programs\python\python311\lib\site-packages\numpy\_core\__init__.py", line 49, in <module>
        raise ImportError(msg)
    ImportError: 

    IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

    Importing the numpy C-extensions failed. This error can happen for
    many reasons, often due to issues with your setup or how NumPy was
    installed.

    We have compiled some common reasons and troubleshooting tips at:

        https://numpy.org/devdocs/user/troubleshooting-importerror.html

    Please note and check the following:

      * The Python version is: Python3.11 from "C:\Program Files\Inkscape\bin\pythonw.exe"
      * The NumPy version is: "2.2.1"

    and make sure that they are the versions you expect.
    Please carefully study the documentation linked above for further help.

    Original error was: No module named 'numpy._core._multiarray_umath'


    The above exception was the direct cause of the following exception:

    Traceback (most recent call last):
      File "C:\Users\jrsid\AppData\Roaming\inkscape\extensions\org.inkscape.extension.29361\simple_inkscape_scripting\simpinkscr\simple_inkscape_scripting.py", line 32, in <module>
        import numpy
      File "c:\users\jrsid\appdata\local\programs\python\python311\lib\site-packages\numpy\__init__.py", line 132, in <module>
        raise ImportError(msg) from e
    ImportError: Error importing numpy: you should not try to import numpy from
            its source directory; please exit the numpy source tree, and relaunch
            your python interpreter from there."

    The python script was:

    "brickWidth, brickHeight = 60, 30
    for row in range(1, 11):
        x0, y0 = (canvas.width - row * brickWidth)/2, row * brickHeight
        for col in range(row):
            red = randcolor(range(64, 192), [0], [0])
            rect((x0 + col * brickWidth, y0), (x0 + (col + 1) * brickWidth, y0 + brickHeight), fill = red)"

    I am running Inkscape v.1.4 in Windows 10. I have Python 3.11 or 3.1.1 installed. Where do I go from here?