简体   繁体   中英

Running a python script from command prompt

I'm working on a tutorial for a big data class and am having trouble in the command line (Windows 7 Pro). I'm not very familiar with the command line environment so this is probably something simple, but here goes:

I have a python script called mapper.py that is stored in the directory

E:\Documents\School\Math\M 461\MapReduce\PythonScripts

and a file named

Medicare_Provider_Util_Payment_PUF_CY2013.txt

that is stored in

E:\Documents\School\Math\M 461\MapReduce\Data

Python (Anaconda) is installed at C:\\Program Files\\Anaconda3 . I'm trying to feed the file to the script and execute it from the command line using

type Medicare_Provider_Util_Payment_PUF_CY2013.txt
| 'C:\Program Files\Anaconda3\python' mapper.py

I use the apostrophes because otherwise it doesn't like the space in Program Files. However, when I execute this command it says that "The filename, directory name, or volume label syntax is incorrect." I'm not sure where to go from here so any guidance would be appreciated.

The text file and the Python file aren't in the same directory, so your example can't work. Try this series of commands in at your command prompt:

First, make the common parent the current directory

E:
cd E:\Documents\School\Math\M 461\MapReduce

Then run your script, giving the path to the data and python files:

type Data\Medicare_Provider_Util_Payment_PUF_CY2013.txt | 'C:\Program Files\Anaconda3\python' PythonScripts\mapper.py

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM