简体   繁体   中英

Why I got “WindowsError [Error5] Access is denied” when run python file using mrjob

I'm trying to use mrjob in a python file and run it in the command line, but I'm keeping getting the error log saying:

C:\Users\Ni\Desktop>python si601lab6_sol.py pg1268.txt
no configs found; falling back on auto-configuration
no configs found; falling back on auto-configuration
creating tmp directory c:\users\ni\appdata\local\temp\si601lab6_sol.Ni.20131019.
052147.951000
writing to c:\users\ni\appdata\local\temp\si601lab6_sol.Ni.20131019.052147.95100
0\step-0-mapper_part-00000
Traceback (most recent call last):
  File "si601lab6_sol.py", line 29, in <module>
    BiGramFreqCount.run()
  File "C:\Python27\lib\site-packages\mrjob\job.py", line 500, in run
    mr_job.execute()
  File "C:\Python27\lib\site-packages\mrjob\job.py", line 518, in execute
    super(MRJob, self).execute()
  File "C:\Python27\lib\site-packages\mrjob\launch.py", line 146, in execute
    self.run_job()
  File "C:\Python27\lib\site-packages\mrjob\launch.py", line 207, in run_job
    runner.run()
  File "C:\Python27\lib\site-packages\mrjob\runner.py", line 458, in run
    self._run()
  File "C:\Python27\lib\site-packages\mrjob\sim.py", line 182, in _run
    self._invoke_step(step_num, 'mapper')
  File "C:\Python27\lib\site-packages\mrjob\sim.py", line 269, in _invoke_step
    working_dir, env)
  File "C:\Python27\lib\site-packages\mrjob\inline.py", line 155, in _run_step
    os.chdir(working_dir)
WindowsError: [Error 5] Access is denied: 'c:\\users\\ni\\appdata\\local\\temp\\
si601lab6_sol.Ni.20131019.052147.951000\\job_local_dir\\0\\mapper\\0'

The python file is really simple:

#!/usr/bin/python

# python si-601-lab-5.py input.txt
# Some codes used courtesy of Dr. Yuhang Wang.

from mrjob.job import MRJob
import re

class BiGramFreqCount(MRJob):

  ### input: self, in_key, in_value
  def mapper(self, _, line):
    yield "chars", len(line)
    yield "words", len(line.split)
    yield "lines",1

    ### Task2: replace this part and use bigram (this word and its next word) as the key
    ###        and skip the last word in each line
    print '== mapper output =='
    for word in words:
      print [word, 1]
      yield(word, 1)
    print

  ### input: self, in_key from mapper, in_value from mapper
  def reducer(self, key, values):
    yield (key, sum(values))

if __name__ == '__main__':
  BiGramFreqCount.run()

I've beening trying to fix this for couple hours but no go... Hope someone can help me out. Thanks!

Problem Solved. When I ran Command Prompt as an administrator, everything works. But I'm still confused because in my user profile properties settings, I am the administrator of the system. So why do I still need to run a program as an administrator? I'm using Win8 in case.

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