ImportError: Missing required dependencies [‘numpy’]

anacondacommand linepython

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

Best Answer

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.