0

I have code that runs over 7000 columns dataset with around 250k records

it works fine when I use Anaconda Spyder

but now I want to put this code to run based on Task Schedule

Therefore I am want to execute the code in cmd Command Prompt as

Python "c:\myfolder\predservice.py"

It didn't work as Task Schedule

I start tracing the problem by running the script on Python from within cmd

I got this error, which I did not get when I was running through Spyder

How can I avoid such error

I thought it is because of the memory. when i select a subset of the dataset it runs fine but when I run the whole dataset i get this error

>>> df =pd.concat([df.drop('PreviousDRGs', 1), pd.get_dummies(df['PreviousDRGs'] .str.split(",", expand=True), prefix
 = 'PreviousDRGs').max(level=0, axis=1).asty pe(np.int8)], axis=1)


 Traceback (most recent call last):   File "<stdin>", line 1, in
 <module>   File
 "C:\Users\decisionsupport\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\generic.py",
 line 11616, in stat_func return self._agg_by_level(name, axis=axis,
 level=level, skipna=skipna)   


 File
 "C:\Users\decisionsupport\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\generic.py",
 line 10440, in _agg_by_level grouped = self.groupby(level=level,
 axis=axis, sort=False)   


 File
 "C:\Users\decisionsupport\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\generic.py",
 line 7894, in groupby **kwargs   



 File
 "C:\Users\decisionsupport\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\groupby\groupby.py",
 line 2522, in groupby return klass(obj, by, **kwds)   



 File
 "C:\Users\decisionsupport\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\groupby\groupby.py",
 line 363, in __init__ obj._consolidate_inplace()   



 File
 "C:\Users\decisionsupport\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\generic.py",
 line 5252, in _consolidate_inplace self._protect_consolidate(f)   



 File
 "C:\Users\decisionsupport\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\generic.py",
 line 5241, in _protect_consolidate result = f()   




 File
 "C:\Users\decisionsupport\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\generic.py",
 line 5250, in f self._data = self._data.consolidate()   



 File
 "C:\Users\decisionsupport\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\internals\managers.py",
 line 932, in consolidate bm._consolidate_inplace()   





 File
 "C:\Users\decisionsupport\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\internals\managers.py",
 line 937, in _consolidate_inplace self.blocks =
 tuple(_consolidate(self.blocks))   




 File
 "C:\Users\decisionsupport\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\internals\managers.py",
 line 1913, in _consolidate list(group_blocks), dtype=dtype,
 _can_consolidate=_can_consolidate   



 File "C:\Users\decisionsupport\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\core\internals\blocks.py",
 line 3323, in _merge_blocks new_values = new_values[argsort]   
 numpy.core._exceptions.MemoryError: Unable to allocate array with
 shape (4524, 1 38299) and data type uint8
>>> 
7
  • Please repaste you traceback and format it as code. It is not readable like this. Commented Aug 26, 2019 at 1:52
  • Are the Python executable that you are calling in the command prompt and the Spyder application both part of the same python installation/environment? Commented Aug 26, 2019 at 2:11
  • @Xukrao I dont call executables. I call .py file Commented Aug 26, 2019 at 2:12
  • When you enter Python "c:\myfolder\predservice.py" in the command prompt you're calling python.exe and feeding it the .py file. The error traceback seems to indicate that this python executable is part of an installation in C:\Users\decisionsupport\AppData\Local\Programs\Python. Is your Spyder application part of this same installation as well, or is it in a separate installation? Commented Aug 26, 2019 at 2:19
  • Just a guess but could it be that Anaconda uses a 64-bit python? Your error traceback shows that your Task Scheduler is running your .py script using a 32-bit python. Commented Aug 26, 2019 at 2:28

2 Answers 2

2

Looks like Anaconda may be using a 64-bit python. Your error traceback shows that your Task Scheduler is running your .py script using a 32-bit python. Either

  1. replace your 32-bit python with a 64-bit version
  2. or install a separate 64-bit python and tell Task Scheduler to use that to run your .py file.
Sign up to request clarification or add additional context in comments.

1 Comment

Belongs as a comment. How do I write a good answer?
0

I think you need to activate your conda base in cmd before calling the script

call <path>\anaconda\Scripts\activate base
<path>\anaconda\python.exe <path>\scriptname.py

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.