I have a script that executes without error using Spyder. The same script results in errors when run from command prompt. I don't know why I get the errors. I spent most of yesterday trying to understand why I get the errors and I failed. So I am here.
At line 9 in my script I have
import numpy
import pandas
import pyodbc
the remainder of the code runs odbc queries, manipulates the query results and saves the manipulated query results someplace else.
My script runs without error in Spyder.
I tried to execute the script at the command prompt running as administrator using the code below (I substituted path for the "C:\Users\RAdams\AppData\ etc"):
C:\path\pythonw.exe C:\path\receiving3.pyw 1>stdout.txt 2>stderr.txt
After executing, "stdout.txt" is blank and "stderr.txt" contains:
Traceback (most recent call last):
File "C:\path\receiving3.pyw", line 9, in <module>
import numpy
File "C:\path\lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "C:\path\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 idea why this would run in Spyder but not in command prompt?
Should I be using something besides command prompt?
My goal is to have this run in Windows Task Scheduler – I thought having it successfully run in command prompt would be appropriate precursor.
Also:
Yesterday I re-installed miniconda. Using conda I then installed jupyter, matplotlib, numpy, openpyxl, pandas, pyodbc, scikit-learn, seaborn, and spyder into base. I have not created any environments.
Best Answer
I created a .bat file with
Using the activate.bat file in miniconda3/scripts lets me use the environment numpy was created in (which I assume is why numpy wouldn't work before).
Everything works now - yay!