pythonpython-3.xoperating-systemanaconda

Not able to write a file , PermissionError [Errno13]


I am writing in a file in Python like this :

result = br.response()
    html=result.read()
    f = open('s.txt','wb')
    f.write(html)

    contents = open("s.txt","r")
    with open("s.html", "w") as e:
        for lines in contents.readlines():
            e.write(lines + "\n")

This file is saved in C:\Users\XX\Anaconda3, and whenever I run it, it's giving me the following error :

  File "c:\users\atharva\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\atharva\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\ATHARVA\Anaconda3\Scripts\iitbbscli.exe\__main__.py", line 9, in <module>
  File "c:\users\atharva\anaconda3\lib\site-packages\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\atharva\anaconda3\lib\site-packages\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "c:\users\atharva\anaconda3\lib\site-packages\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\atharva\anaconda3\lib\site-packages\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\atharva\anaconda3\lib\site-packages\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "c:\users\atharva\anaconda3\lib\site-packages\iitbbscli\app.py", line 82, in attendance
    f = open('s.txt','wb')
PermissionError: [Errno 13] Permission denied: 's.txt'

How can I overcome this error?


Solution

  • Run IDE with administration permission