PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, October 19, 2022

[FIXED] How do I give PyCharm Admin permission?

 October 19, 2022     admin, pycharm, python     No comments   

Issue

Having a hard time reading this excel file. I did some googling and it looked like I needed to give PyCharm admin permission. So I exited out and then "ran as administrator". Still having the same error. Not even sure if that the actual problem or if I'm doing something else wrong.

my code

import xlrd

loc = (r"C:\Users\tyler\OneDrive\Documents\GB-NYJ 2002 W17.xlsx")

wb = xlrd.open_workbook(loc)
sheet = wb.sheet_by_index(0)
print(sheet.cell_value(0, 0))

the error

C:\Users\tyler\PycharmProjects\NFLModel\venv\Scripts\python.exe C:/Users/tyler/PycharmProjects/NFLModel/Carson.py
Traceback (most recent call last):
  File "C:/Users/tyler/PycharmProjects/NFLModel/Carson.py", line 10, in <module>
    wb = xlrd.open_workbook(loc)
  File "C:\Users\tyler\PycharmProjects\NFLModel\venv\lib\site-packages\xlrd\__init__.py", line 111, in open_workbook
    with open(filename, "rb") as f:
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\tyler\\OneDrive\\Documents\\GB-NYJ 2002 W17.xlsx'

Process finished with exit code 1

Solution

So I got it to work. Unfortunately I'm not 100% sure what exactly the issue was. So I'll just rundown the steps I tool

  1. run pycharm with admin permission
  2. Set Configuration to the file that's running
  3. Create init file

At this point it was still not working

  1. Restart computer. Then it worked lol

Someone suggested that Windows could have been running Excel in the background and that was stopping python from accessing the file. Like I said though, can't be 100% that was the sole issue.



Answered By - tyl-er
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing