Sublime Text has forgotten where to find openpyxl and I can't figure out how to teach it

44 Views Asked by At

I come to you a broken man.

Sublime Text has me absolutely stumped. Background: MacOS, Sonoma 14.3.1. Sublime Text 3.

I am working on a project that requires me to read and write Excel files, so I have been using my old friend openpyxl in Python. Things were going great.

Until I got stuck refactoring some data structures along different axes, and decided to use pandas. When I started using pandas, I became quickly confused, and decided to install jupyter notebook so that I would have a more low-latency experience figuring out how to manipulate the data into the form that I needed.

The standard installation of jupyter failed on my Mac, so I tried Homebrew. Homebrew didn't really do anything that I could figure out how to start, so I went to Anaconda. Anaconda installed OK, but I then realized that pandas was extreme overkill for what I wanted to do anyway, and I decided to go the simple route of starting out with nested dicts instead of lists holding dicts, which made addressing the information that I needed much easier.

HOWEVER, now when I try to run my script in SublimeText, I get the following error:

ModuleNotFoundError: No module named 'openpyxl'
...
[path: /opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/anaconda3/bin:/opt/homebrew/bin:/opt/homebrew/sbin]

Fine. No problem. Openpyxl must have been deleted by Anaconda or something. I know how to reinstall it:

pip install openpyxl

Tragedy ensues: I see the following error:

Requirement already satisfied: openpyxl in /opt/homebrew/lib/python3.11/site-packages (3.1.2)
Requirement already satisfied: et-xmlfile in /opt/homebrew/lib/python3.11/site-packages (from openpyxl) (1.1.0)

So, I HAVE openpyxl, but Sublime Text doesn't KNOW that I have openpyxl. Anymore. Because it was able to find openpyxl for years until I messed around with Homebrew and/or Anaconda. Now it has no idea where to find it.

SO, I tried adding the Homebrew path to a new ~/.bash-profile:

export PYTHONPATH="/opt/homebrew/lib/python3.11/site-packages (3.1.2)"

Sublime Text dutifully reloaded the new .bash-profile after I saved it, but nothing changed and I got the same error as before.

I also removed the binary from the Mac Applications folder, and reinstalled Sublime Text using Homebrew in the hopes that perhaps Homebrew Sublime Text would be able to find Homebrew openpyxl, but to no avail. Although the good news is that at least now I can start Sublime from the terminal again, which is something that I had been missing.

I am at the bottom of my bag of tricks. I have absolutely no idea what is going on, and so if anyone has any inkling of what has happened to my faithful Sublime Text to induce this sudden bout of amnesia, or how to fix it, I would be extremely grateful.

Many thanks. Sublime Text is the app that I spend the most time in, so this is a bit of a shock for me, hence the dramatics. Any help is greatly appreciated.

0

There are 0 best solutions below