I have looked various posts about python not getting the installed library. I tried using python -m pip install PyPDF2 to get this library installed but no luck.
Asked
Active
Viewed 506 times
1

Demon
- 826
- 7
- 22
-
other modules have worked just fine? – JeffCharter Oct 10 '18 at 01:31
-
Anything preinstalled with ArcGIS works fine. – Demon Oct 10 '18 at 01:33
-
Possible duplicate of [How do I install pyPDF2 module using windows?](https://stackoverflow.com/questions/22106380/how-do-i-install-pypdf2-module-using-windows) – Lukas Oct 10 '18 at 01:35
-
It could be a python path problem - try closing your C:\Python27 term and open it up again. – JeffCharter Oct 10 '18 at 01:36
-
also what does this show: import site; site.getsitepackages() – JeffCharter Oct 10 '18 at 01:38
-
tried doing that. I am getting the same error again. i will try the next thing you said. – Demon Oct 10 '18 at 01:38
-
@JeffCharter I have posted a picture of the output – Demon Oct 10 '18 at 01:40
-
https://stackoverflow.com/questions/25224260/pypdf2-wont-import – Lukas Oct 10 '18 at 01:41
-
restart computer? xD – Lukas Oct 10 '18 at 01:42
-
@Lukas I have tried doing pip install pypdf2 – Demon Oct 10 '18 at 01:42
-
did you tried 'import pypdf2' lowcase? Did you try install it by downloading from PyPI, then running setup.py install? – Lukas Oct 10 '18 at 01:43
-
@Lukas Yes. I have. – Demon Oct 10 '18 at 01:45
-
Ok when restart computer, manually downloading form PyPi then running setup.py install not helps, try this - [click here](https://stackoverflow.com/questions/41501636/how-to-install-pip3-on-windows) – Lukas Oct 10 '18 at 01:50
-
not running Linux..... – Demon Oct 10 '18 at 01:51
-
try these 2 line in your python terminal 1.import sys 2.sys.path.append('c:\python27\argis10.5\lib\site-packages') – JeffCharter Oct 10 '18 at 02:05
-
https://stackoverflow.com/questions/7472436/add-a-directory-to-python-sys-path-so-that-its-included-each-time-i-use-python – JeffCharter Oct 10 '18 at 02:08
-
@JeffCharter thanks that work except that I had to type in the console as `import PyPDF2` after that. Please put that your comment as answer so I can give you points for it. – Demon Oct 10 '18 at 02:10
1 Answers
1
It looks like your PyPDF2 module is install inside the arcgis sub-directory If you add this to the top of your script that should do it
import sys
sys.path.append('c:\python27\argis10.5\lib\site-packages')
import PyPDF2
If you need you can also look into modifying your PYTHONPATH
Edit adding on to Jeff's answer:
I added a new pythonpath variable in environmental variables that I was missing to direct the python console to C:\Python27\ArcGIS10.5\Lib\site-packages

Demon
- 826
- 7
- 22

JeffCharter
- 1,431
- 17
- 27