0

I have a Project working in PyCharm with the Anaconda3 Python 3.7 interpreter. When I run it from PyCharm there is no issue, but when I run it from cmd (same interpreter) with:

c:\users\xxx\appdata\local\continuum\anaconda3\python main.py

I get:

    File "c:\Users\xxx\PycharmProjects\LibreriaDerivados\Calculator\Calculator.py", line 1, in <module>
    import numpy as np
  File "c:\users\xxx\appdata\local\continuum\anaconda3\lib\site-packages\numpy\__init__.py", line 140, in <module>
    from . import _distributor_init
  File "c:\users\xxx\appdata\local\continuum\anaconda3\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
    from . import _mklinit
ImportError: DLL load failed: The specified module could not be found.

So I checked just accessing Python in cmd works, but then inside when I do import numpy I get the same error.

Additional info:

  • dir C:\users\xxx\AppData\Local\Continuum\anaconda3\Lib\site-packages\numpy exists.
  • Inside that dir __init__.py, __distributor_init.py files exist, but no _mklinit file.
  • There is a _mklinit.cp37-win_amd64.pyd file. Making a copy named _mklinit.pyd won't help.
  • Maybe these are different python.exe in cmd in PyCharm? Try checking with `which python` or `where python` to make sure which executable is invoked. – Evgeny Jul 08 '20 at 21:23
  • @Evgeny `where python` does return a different Python path from the one that PyCharm uses, but as I mentioned, to run my Project in `cmd` I first navigated to the PyCharm interpreter folder (…\Continuum\anaconda3\) and then run `python main.py` – Oliver Mohr Bonometti Jul 08 '20 at 21:49
  • I might be wrong, but running just different interpreter isn't enough - the import of libraries still goes from folders found on PATH, I suspect. Either you carve out another python installation, or change PATH or use virtual envs, these are the options. – Evgeny Jul 09 '20 at 14:00

2 Answers2

0

Ok I remember a long time ago I had this same issue

I solved it by going to my cmd, and going to the python scripts directory

cd "C:\Users\micha\AppData\Local\Programs\Python\Python38-32\Scripts"

THEN do pip install Whatever, then it should work

Or check your PATH maybe

MichaelT572
  • 178
  • 1
  • 9
-1

A similar issue was resolved here with matplotlib not being found. Not sure if your issue is exactly the same but here's their solution:

(I found this answer from a video: http://www.youtube.com/watch?v=xmvRF7koJ5E)

  1. Download msvcp71.dll and msvcr71.dll from the web.

  2. Save them to your C:\Windows\System32 folder.

  3. Save them to your C:\Windows\SysWOW64 folder as well (if you have a 64-bit operating system).

jizhihaoSAMA
  • 12,336
  • 9
  • 27
  • 49
Kel Varnsen
  • 314
  • 2
  • 8