Running python script from VBA using Shell does no

2019-08-15 05:50发布

问题:

the below code is executing simple python script from Windows excel VBA Shell on 1 machine, but not on the other.

 Sub RunIt()
    CreateObject("wscript.shell").Run "python.exe " & """\\acntnyc039\dept\HGS\Bob\test_syst_arg2.py""", 1, True
    'same as
    Shell "python.exe ""\\acntnyc039\dept\HGS\Bob\test_syst_arg2.py""", 1
End Sub

corresponding python:

import pandas as pd
import sys
path = r'\\acntnyc039\dept\HGS\Bob\test\test.csv'

raw_data = {'first_name': ['Jason', 'Molly', 'Tina', 'Jake', 'Amy'], 
        'last_name': ['Miller', 'Jacobson', 'Ali', 'Milner', 'Cooze'], 
        'age': [42, 52, 36, 24, 73], 
        'preTestScore': [4, 24, 31, 2, 3],
        'postTestScore': [25, 94, 57, 62, 70]}
df = pd.DataFrame(raw_data, columns = ['first_name', 'last_name', 'age',
                                       'preTestScore', 'postTestScore'])
df.to_csv(path)

i've read all similar threads and checked the following:

  1. both users have identical non-admin access, yet it does not execute for one of them producing no error message (but cmd opens)
  2. network path does not have spaces
  3. the same line runs just fine from cmd directly
  4. python is found when typing python from cmd, but still tried replacing python with python.exe along with full path to python.exe in VBA string above to no avail
  5. full anaconda3 reinstall did not fix the problem
  6. shell seems to be working fine on non-python code as in:

Shell "notepad.exe ""\\acntnyc039\dept\HGS\Bob\test\test.csv""", 1

i'm really running out of ideas here ...