Bug #1975

Failed to import numpy on Windows (in virtual environment)

Added by pospelov over 2 years ago. Updated over 2 years ago.

Status:RejectedStart date:22 Feb 2018
Priority:LowDue date:
Assignee:dmitry% Done:

0%

Category:-
Target version:Sprint 37

Description

  • BornAgain + Win10 at home + Anaconda + Pycharm
C:\Users\chebyrashka\PycharmProjects\untitled\venv\Scripts\python.exe C:/BornAgain-1.10.99/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationDA.py
ImportError: numpy.core.multiarray failed to import
Traceback (most recent call last):
  File "C:/BornAgain-1.10.99/Examples/python/simulation/ex03_InterferenceFunctions/ApproximationDA.py", line 4, in <module>
    import bornagain as ba
  File "C:\BornAgain-1.10.99\python\bornagain\__init__.py", line 7, in <module>
    from libBornAgainFit import *
  File "C:\BornAgain-1.10.99\bin\libBornAgainFit.py", line 28, in <module>
    _libBornAgainFit = swig_import_helper()
  File "C:\BornAgain-1.10.99\bin\libBornAgainFit.py", line 24, in swig_import_helper
    _mod = imp.load_module('_libBornAgainFit', fp, pathname, description)
  File "C:\Users\chebyrashka\PycharmProjects\untitled\venv\lib\imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\chebyrashka\PycharmProjects\untitled\venv\lib\imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: numpy.core.multiarray failed to import

According to dependency walker launched on libBornAgainFit.pyd there is circular dependency, see screnshot

DependencyWalker1.png (166 KB) pospelov, 22 Feb 2018 20:54

VirtualEnv.png (15.7 KB) pospelov, 22 Feb 2018 21:28

History

#1 Updated by pospelov over 2 years ago

  • File VirtualEnv.png added
  • Subject changed from Failed to import numpy on Windows to Failed to import numpy on Windows (in virtual environment)
  • Assignee deleted (pospelov)
  • Priority changed from High to Low

Apparently it happens only if PyCharm project is created in virtual environment.
Steps to reproduce:

  • Install Anaconda3
  • Install BornAgain on Windows
  • Install PyCharm
  • Create project as shown on screenshot
  • Add to the project BornAgain's Python examples
  • Run example in PyCharm -> it will crash on numpy load with circular dependency involved

Before doing all this, try to run BornAgain in Python+ virtualenv on Linux

#2 Updated by dmitry over 2 years ago

The error is reproduced under linux

#3 Updated by dmitry over 2 years ago

  • Assignee set to dmitry

#4 Updated by dmitry over 2 years ago

  • Status changed from Sprint to Rejected

This error reproduced both on linux and windows, given numpy not installed in virtual environment (the message looks a little bit different in linux). It also doesn't depend, whether anaconda or another distribution is used as the basis. Moreover, pycharm + anaconda don't give an option to install numpy in venv. Specialized conda environment should be used instead.

Also available in: Atom PDF