Description
In ArcGIS Notebooks within ArcGIS Pro, an error message is returned when a pdfkit Python module is imported.
Error:
ModuleNotFoundError: No module named 'pdfkit'
Cause
- The pdfkit module is not installed in any environment on the machine.
- The pdfkit module is installed outside the ArcGIS Pro Python environment. ArcGIS Pro uses its own isolated Python environment and in this example, the module is installed in the Windows Command Prompt therefore it cannot be detected.
Solution or Workaround
Depending on the cause, the options below are applicable.
Note:
To install the pdfkit module successfully in the notebook, clone the default ArcGIS Pro Python environment using Package Manager. Refer to ArcGIS Pro: Clone an environment for more information.
Install the pdfkit using the ArcGIS Pro Python Command Prompt
- In the Windows taskbar search box, search for and right-click Python Command Prompt > Run as administrator.
Note:
Proceed to Step 3 if the ArcGIS Pro Python cloned environment is activated.
- Switch to the ArcGIS Pro Python cloned environment. Press Enter.
activate arcgispro-py3-clone
- Install the pdfkit using pip install in the command prompt. Press Enter.
pip install pdfkit
- In ArcGIS Pro, open Python Notebook and ensure Code is selected as the cell type.
- Copy and paste the following command into the cell.
import pdfkit
- Click the Run this cell and advance (Shift +Enter)
icon found above the cell.
Uninstall and reinstall pdfkit in the correct environment
Note:
This workflow is not applicable if the pdfkit is installed in an environment other than Windows Command Prompt.
- In the Windows taskbar search box, search for and right-click Command Prompt > Run as administrator.
- Check the previous installation path of the pdfkit using pip show. Press Enter.
pip show pdfkit
- Remove the previous pdfkit installation using pip uninstall. Press Enter.
pip uninstall pdfkit
Note:
Alternatively, copy the pdfkit location path displayed in Step 2, paste it in File Explorer to locate the file, and manually delete the file.
- Refer to the first solution to reinstall the pdfkit in the correct Python environment and import it into the notebook.