Numpy importing with BAT file execution fails
See original GitHub issueReproducing code example:
I am trying to execute a .py file by running a .bat file through task scheduler. When I do that I get the error message below. When I run the .py file in an ide (I work w/ spyder I don’t have this problem) I have tried to uninstall numpy several times. I have reinstallaed several versions. I have tried w/ 1.16.6 but now working w/ 1.18.1
Obviously. Thank you in advance for any help you can provide.
import numpy as np
Error message:
C:\Users\GB New Lenovo\Anaconda\Install\lib\site-packages\numpy_init_.py:140: UserWarning: mkl-service package failed to import, therefore Intel® MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service from . import distributor_init Traceback (most recent call last): File “D:\Resilio\Nanodegree 1\Finance\Scraping_code\WSJ_bond_benchmark\WSJ_Bond_Benchmarks.py”, line 10, in <module> import pandas as pd File "C:\Users\GB New Lenovo\Anaconda\Install\lib\site-packages\pandas_init.py", line 17, in <module> “Unable to import required dependencies:\n” + “\n”.join(missing_dependencies) ImportError: Unable to import required dependencies: numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
-
Try uninstalling and reinstalling numpy.
-
If you have already done that, then:
- Check that you expected to use Python3.6 from “C:\Users#########\Anaconda\Install\python.exe”, and that you have no directories in your PATH or PYTHONPATH that can interfere with the Python and numpy version “1.18.1” you’re trying to use.
- If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
-
If you’re working with a numpy git repository, try
git clean -xdf(removes all files not under version control) and rebuild numpy.
Note: this error has many possible causes, so please don’t comment on an existing issue about this - open a new one instead.
Original error was: DLL load failed: The specified module could not be found.
Numpy/Python version information:
numpy version 1.18.1 Windows 10 Pro Version 1903 OS Buil 18362.657
I installed numby through anaconda prompt I beleive I installed python w/ the anaconda installation I have python 2.7 and python 3.6 installed.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)

Top Related StackOverflow Question
@mattip Thank you for clarifying, that solved the problem! I’m still curious how PyCharm and Spyder manage to solve the issue while only calling the environment python.exe directly.
For reference, here is the batch file that worked for me:
Good to know that the Anaconda environment should be activated when possible.
Minor Edit:
C:\Users\myuser\Anaconda3\condabin\conda activate test_numpywill work in the command line, but you need to usecall C:\Users\myuser\Anaconda3\condabin\conda activate test_numpyif you are running a batch file.See https://stackoverflow.com/questions/24678144/conda-environments-and-bat-files
You should add something like
where you replace
<myenv>with your environment name into your batch file. For more information, see the link in the comment above. So your batch file should be something like