I am using PyPDF2 to combine multiple PDF files into an output. While my code was working before, it has stopped after moving the file into a different folder on my computer. The package can no longer be found: ModuleNotFoundError: No module named 'PyPDF2'
.
I started by running pip list
to make sure the package was still there (it was). I then tried uninstalling and reinstalling it to no luck. Then, I tried moving into a virtual environment, to see if installing the package there would fix my issue. It did, and the code ran fine, however, I need this to work outside of a venv. I've removed all packages from my non-virtual environment and am left with only this:
Dr-Bubbles:Scripts $ pip list
Package Version
---------- -------
pip 21.0.1
PyPDF2 1.26.0
setuptools 51.3.3
wheel 0.36.2
Dr-Bubbles:Scripts $ python3 mergePdf.py
Traceback (most recent call last):
File "mergePdf.py", line 10, in <module>
from PyPDF2 import PdfFileReader, PdfFileMerger
ModuleNotFoundError: No module named 'PyPDF2'
For reference, here is import part of the script:
from PyPDF2 import PdfFileReader, PdfFileMerger
from rich import print
OUTPUT_DIR = "/Users/bencarpenter/OneDrive/Personal/PDFs"
def main():
# Main function
Does anyone know where I went wrong? I'm open to any ideas. Many thanks!
I found it. My issue was with dual installs of python3. pip is attached to my homebrew install of python but running python3
in the cli was running the system install. To fix this, I added the line alias python=/usr/local/bin/python3
to my .zshrc
file (as shown here), making it so that running python3 always points to the hombrew install. Thank you to @Fatalerr for pointing me in the right direction.