Difficulty in installing PyPDF2 and PCMUPDF

Unfortunately, in my experience, Jupyter has surprisingly limited convenience facilities for easily working in multiple environments compared to other scientific IDEs like Spyder. However, assuming this is just a matter of ensuring packages install in the same environment as the Jupyter kernel you are running, this comes down to one of two options:

  • Launch Jupyter Notebook in whatever Python environment you are installing packages into by typing jupyter notebook at the same command prompt. Of course, this assumes it is installed there (or you install it).
  • Figure out what Python environment Jupyter is using by checking the output of import sys; print(sys.executable) in your Jupyter Notebook. This will give either the path to the base Python install, or to the specific virtual/conda env being used. Then, activate that environment in your command prompt (will vary depending on what it is and how you installed Jupyter), and run your install commands again.

You could also running the install commands directly inside your Jupyter notebook by prefixing them with !, e.g. !pip install pypdf2, but there is no guarantee that actually works correctly, and could cause further problems.

If you still can’t figure it out, copy/paste the full, exact output of, at minimum, where python in the command prompt you are installing the packages, and import sys; print(sys.executable) inside your Jupyter notebook, inside a code block (use </> in the toolbar, or the following Markdown syntax:

```
YOUR FULL COMMAND OUTPUT HERE
```

This will allow us to determine where the Python environments you’re installing into and running your notebook in, respectively, are located so we can advise you how to use the latter with the former.

1 Like