ImportError: Missing required dependencies ['numpy']

2

4

I'm trying to schedule some python script with the Windows scheduler. Unfortunately, I run into the following error when I try to execute my script from the Command Prompt:

"Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']

The code I'm trying to run is fairly simple and only uses the following imports:

import pandas as pd
import xlwings as xw
import datetime as dt
import pyodbc

When running the code from Anaconda prompt (and using the desired environment) everything works fine:

(scheduler_env) C:\Users\a316283\Desktop\SQLProcessing\ScheduledReality>UpdateScheduledReality.py

In Jupyter Notebook (in the same environment) everything works perfect as well.

Running the following in Command Prompt on the other hand side yields:

C:\>C:\Users\a316283\.julia\conda\3\envs\scheduler_env\python.exe C:\Users\a316283\Desktop\SQLProcessing\ScheduledReality\UpdateScheduledReality.py

Traceback (most recent call last):
  File "C:\Users\a316283\Desktop\SQLProcessing\ScheduledReality\UpdateScheduledReality.py", line 1, in <module>
    import pandas as pd
  File "C:\Users\a316283\.julia\conda\3\envs\scheduler_env\lib\site-packages\pandas\__init__.py", line 19, in <module>
    "Missing required dependencies {0}".format(missing_dependencies))
ImportError: Missing required dependencies ['numpy']

Drilling a bit further down and just running python in this environment:

C:\Users\a316283\.julia\conda\3\envs\scheduler_env>python.exe

Yield a similar error when trying to import numpy:

>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\a316283\.julia\conda\3\envs\scheduler_env\lib\site-packages\numpy\__init__.py", line 140, in <module>
    from . import _distributor_init
  File "C:\Users\a316283\.julia\conda\3\envs\scheduler_env\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.
>>>

Any advice is more than welcome. Thanks.

*** I tried this in different environments, including my base environment, but I keep running in the same error. I uninstalled en reinstalled numpy and pandas in all my environments, without any result.

EDIT: Solved this problem, try following these steps:

  • Run the command prompt and run python
  • Try to import pandas ; you should get the above mentioned error
  • Check if you got the following warning upon opening python: Warning: This Python interpreter is in a conda environment, but the environment has not been activated. Libraries may fail to load. To activate this environment please see https://conda.io/activation
  • Close python (exit())
  • Activate your environment (base in my case): activate base
  • Run Python scripts

Steven Van Dorpe

Posted 2019-03-12T08:26:55.537

Reputation: 121

Answers

2

I was getting crazy about the exact same thing. My script was working fine in Spyder AND in CONDA prompt BUT NOT in a standard CMD/PowerShell. I found this link in the PowerBI community that also presented the same problem.

Everything was correctly installed, checked with conda list --revisions.

After digging a bit, I was sure it was a PATH problem. So, I did these steps:

  1. Update Anaconda (conda update --all)
  2. Manually update the PATH variable in my System Variables with these values:

    C:\ProgramData\Anaconda3 C:\ProgramData\Anaconda3\Library\mingw-w64\bin C:\ProgramData\Anaconda3\Library\usr\bin C:\ProgramData\Anaconda3\Scripts

Now my Python scripts runs from a CMD/PS window without the error ImportError: Missing required dependencies ['numpy'].

Hope this helps.

Massimo Nitri

Posted 2019-03-12T08:26:55.537

Reputation: 21

Updated anaconda as you described and updated the PATH variable in my System Variables. I couldn't seem to find the 'usr' folder in 'Anaconda3\Library'. Do you have any idea why this could be missing? After updating all this CMD execution still does not work. – Steven Van Dorpe – 2019-03-26T07:41:21.803

Sorry, no idea. I installed Anaconda using its wizard, without even changing the installation path, I presume the basic path should be the ones I described, if the installation works fine.

I used this link: https://repo.anaconda.com/archive/Anaconda3-2018.12-Windows-x86_64.exe

– Massimo Nitri – 2019-03-29T09:02:36.960