Forums

unable to import numpy in website

hi everyone,

I have created virtualenv of python 3.6 and installed in it pandas and and sklearn. While using the virtualenv on the console there is now problem to import those packages. But when I am trying to import those in the webapp (after I have integrated the virtualenv in the app (following the instructions in https://help.pythonanywhere.com/pages/Virtualenvs) I am getting the following error:

    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python3.8/site-packages/pandas/__init__.py", line 11, in <module>
        __import__(dependency)
      File "/usr/lib/python3.8/site-packages/numpy/__init__.py", line 142, in <module>
        from . import core
      File "/usr/lib/python3.8/site-packages/numpy/core/__init__.py", line 17, in <module>
        from . import multiarray
      File "/usr/lib/python3.8/site-packages/numpy/core/multiarray.py", line 14, in <module>
        from . import overrides
      File "/usr/lib/python3.8/site-packages/numpy/core/overrides.py", line 16, in <module>
        add_docstring(
    RuntimeError: implement_array_function method already has a docstring

It's seems that it's trying to get numpy out of the virtualenv but I don't know why.

thank you for your help

Omri

[edit by admin: formatting]

Where are you seeing that stack trace? You mention that you're trying to import it in the webapp, but the stack trace has this:

  File "<stdin>", line 1, in <module>

...which looks like you are trying to run it from the editor. Recent versions of numpy won't work in our editor if you try to run it twice -- you have to exit the console at the bottom of the screen by running exit() before hitting the run button again. But that said, you don't need to run website code from the editor -- once it is configured on the "Web" page it will run.