0

I have a long code with a series of imports. For days now I've been running and rerunning this code, including all the imports, for every small change I make (all variable-related, not touching the modules). I keep doing this when suddenly, one time, I get a ImportError: cannot import name _distributor_init upon running import numpy as np. I am, of course, 100% certain that whatever change I made has nothing to do with this import, especially as this is the first executable line in the file, but regardless I reverted that change yet the error continues.

Following some other threads on StackOverflow I tried reinstalling by doing conda install numpy --force-reinstall, this is because in PyCharm and the conda prompt I can clearly see that numpy is installed and up to date. According to this thread, I tried running from the console, and according to a comment here I tried commenting out the respective line in the __init__.py file, but somewhat expectantly none of that worked.

I am using Miniconda3 and the environment runs Python 3.7. IDE is PyCharm in which the interpreter is the aforementioned environment.

The full error is:

Traceback (most recent call last):
  File "<input>", line 7, in <module>
  File "C:\Program Files\JetBrains\PyCharm 2019.1.3\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\OfirL1\Miniconda3\lib\site-packages\numpy\__init__.py", line 140, in <module>
    from . import _distributor_init
ImportError: cannot import name _distributor_init

Aside of having numpy import as usual, which would be nice, I'd love to know what went wrong. This is not the first time that during normal work one module suddenly stops working all of a sudden for no apparent reason.

Ronny Efronny
  • 1,148
  • 9
  • 28
  • Are you sure that you didn't suddenly change working directories? And also are you sure that you did not move any folders around, or added a module/file with the same name as another module? – WiseDev Jul 04 '19 at 10:50
  • What I did before this was look at PyCharm's history log and create a patch out of a previous file, I have since deleted the patch. I have not changed the WD, and have not added any modules like numpy. – Ronny Efronny Jul 04 '19 at 10:58

0 Answers0