简体   繁体   中英

Importing the multiarray numpy extension module failed on different drive

I have Win7 SP1 on VirtualBox with Anaconda 5.2 + Python 3.6.5 32-bit installed. I get the following error when running this python code, and I still cannot pin point the root cause of the problem. Please help...

>> type test.py
import numpy as np    
np.random.seed(42)
print(np.random.randint(1, 101, 100))


>> python test.py
Traceback (most recent call last):
  File "C:\Users\JC\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 16, in <module>
    from . import multiarray
ImportError: DLL load failed: The specified path is invalid.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".\test.py", line 1, in <module>
    import numpy as np
  File "C:\Users\JC\Anaconda3\lib\site-packages\numpy\__init__.py", line 158, in <module>
    from . import add_newdocs
  File "C:\Users\JC\Anaconda3\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "C:\Users\JC\Anaconda3\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
    from .type_check import *
  File "C:\Users\JC\Anaconda3\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "C:\Users\JC\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 26, in <module>
    raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: DLL load failed: The specified path is invalid.

I have installed Anaconda on C-drive, and store my python codes on J-drive.

1. The code run fine when:

  • run the code from C-drive

    • launch cmd.exe from start menu
    • run the code with python J:\\my_codes\\test.py
    • code works fine
  • copy the code from J-drive to C-drive, and run on C-drive

    • copy test.py to C-drive C:\\my_codes\\test.py
    • launch cmd.exe from start menu
    • run the code with python C:\\my_codes\\test.py
    • code works fine
  • run the code manually within the ipython console on C-drive

    • launch cmd.exe from start menu
    • launch the 'ipython` console
    • the code import numpy as np also works fine

2. However, I get the error when:

  • run the code from J-drive

    • launch cmd.exe from start menu
    • cd J:\\my_codes
    • run code with python test.py
    • get the ImportError message
  • run the code manually within the ipython console on J-drive

    • launch cmd.exe from start menu
    • cd J:\\my_codes
    • launch the 'ipython` console
    • try to run import numpy as np
    • get the ImportError message

I do not have this issue before upgrading to Anaconda 5.2 on my VM. Any idea how to fix this issue? Thanks

Somehow I think fix this problem by reinstalling VirtualBox + Extension Pack, Anaconda 5.2 and Sublime Text3. I also make sure the Environment Path for ST3 was inserted after "Anaconda's Path"... Somehow this combo resolve the issue. Now I can move on...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM