简体   繁体   中英

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

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.

The better approach would be to use virtualenv This would have allowed you to install any package without requiring elevated permissions.

You can get a quick guide by visiting https://www.dabapps.com/blog/introduction-to-pip-and-virtualenv-python/

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