Search code examples
pythonioerror

IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/finsymbols/SP500.html'


I installed a package finsymbols in python by

pip install finsymbols

the installation went fine. But when I tried to work with that, there was an error saying that permission denied. The code I have tried is

>>>import finsymbols
>>>sp500 = finsymbols.get_sp500_symbols()
    Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/finsymbols/symbols.py", line 8, in get_sp500_symbols
    page_html = wiki_html('List_of_S%26P_500_companies', 'SP500.html')
  File "/usr/local/lib/python2.7/dist-packages/finsymbols/symbol_helper.py", line 94, in wiki_html
    save_file(file_path, wiki_html)
  File "/usr/local/lib/python2.7/dist-packages/finsymbols/symbol_helper.py", line 39, in save_file
    saved_file = open(file_path, "w")
IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/finsymbols/SP500.html'

can anyone help me in solving this ? Thanks


Solution

  • The cause of the error is that you do not have write access to the finsymbols package folder.

    Give the folder write access and try again:

    sudo chmod a+w /usr/local/lib/python2.7/dist-packages/finsymbols
    

    If you do not want to give access to that folder, run your python as a root user.