Python Forum
Openpyxl module breaking my code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Openpyxl module breaking my code
#1
I was working on a discord bot and wanted to scrape data from an excel spreadsheet so I installed the pandas library and imported it into my file. I wrote up a simple script and tried to run the file but nothing happened. I was confused so I tried to retrace my steps and eventually came to just editing out the import statement and my code ran again. I thought maybe just something wrong with the library so I moved to openpyxl and same thing. I then created a new file, imported openpyxl and ran a simple print statement. Nothing once more. So I commented out the import statement and then it worked. I don't get any errors when trying to run the code, it just simply does nothing. The terminal looks normal as if I had nothing to run in my file, when I clearly have a print statement.

import openpyxl

print("Hello")
That's what my code looks like when it doesn't work, and simply by commenting out the import statement and running again, the print statement executes. I really have no idea how to fix this problem or what might be going on.
Reply
#2
Could you do
import openpyxl
print(openpyxl.__file__)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(May-26-2023, 10:58 AM)buran Wrote: Could you do
import openpyxl
print(openpyxl.__file__)

Hmm I tried that and still nothing. I also tried uninstalling the library and reinstalling it but no difference
Reply
#4
My guess is that you have some openpyxl.py file that waits for input and shadows the package, although in this case pandas would probably raise some error. How do you run the scripts - inside IDE, from terminal?
Can you share some screenshot of running some script that imports openpyxl?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
(May-26-2023, 04:16 PM)buran Wrote: My guess is that you have some openpyxl.py file that waits for input and shadows the package, although in this case pandas would probably raise some error. How do you run the scripts - inside IDE, from terminal?
Can you share some screenshot of running some script that imports openpyxl?

I run it straight from VS code. I also tried using a virtual environment but no difference.
[Image: image.png?width=1025&height=417]
Reply
#6
Image do not show what's important which interpreter usage down in right corner.
Look at this Post and the start in Thread.
So this was for using Virtual environment,it just a interpreter change in VS Code if want to use Python that you has install on OS.
Test that all work on command line first,so you know Python version and where pip install.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  ChromeDriver breaking Python script genericusername12414 1 323 Mar-14-2024, 09:39 AM
Last Post: snippsat
  How to run code again in module ? rajamani 2 912 Nov-10-2022, 02:38 PM
Last Post: snippsat
  breaking out of nested loops Skaperen 3 1,233 Jul-18-2022, 12:59 AM
Last Post: Skaperen
  How to use += after breaking for loop? Frankduc 2 1,496 Dec-31-2021, 01:23 PM
Last Post: Frankduc
  How to fix while loop breaking off raphy11574 3 2,197 Oct-12-2021, 12:56 PM
Last Post: deanhystad
  breaking a large program into functions, not acting as expected Zane217 9 3,030 Sep-18-2021, 12:37 AM
Last Post: Zane217
  Need to run 100+ Chrome’s with Selenium but can’t get past ~15 without breaking imillz 0 1,371 Sep-04-2021, 04:51 PM
Last Post: imillz
Exclamation Help in breaking bytes into bits through masking and shifting kamui123 9 4,592 Jan-11-2021, 07:42 AM
Last Post: kamui123
  [split] openpyxl workbook module not callable yosoyebj 1 2,796 Sep-14-2020, 10:18 AM
Last Post: buran
  Python3 openpyxl module GHULIEV 0 1,503 Aug-07-2020, 08:50 PM
Last Post: GHULIEV

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020