0

I've installed PyPDF2.

$ sudo pip install PyPDF2

It was successfully installed.

Collecting PyPDF2
Installing collected packages: PyPDF2
Successfully installed PyPDF2-1.26.0

But when I run my project, it produce an error.

ImportError: No module named 'PyPDF2'
Server with PID 19740 exited with code 1.
Waiting for changes before reloading.

Of course my project runs if I comment this module but I need it. For those who can help thanks in advance!

Just for additional info, I'm using Ubuntu 16.04.2 LTS and I'm using Pyramid as my framework (Python).

I try to use

pip install PyPDF2

but

  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/pyPdf'

EDIT: output of pip freeze

adium-theme-ubuntu==0.3.4
beautifulsoup4==4.4.1
Chameleon==2.24
chardet==2.3.0
cryptography==1.2.3
dnspython==1.12.0
enum34==1.1.2
FormEncode==1.3.0
html5lib==0.999
idna==2.0
ipaddress==1.0.16
lxml==3.5.0
Mako==1.0.3
MarkupSafe==0.23
Paste==1.7.5.1
PasteDeploy==1.5.2
PasteScript==1.7.5
pyasn1==0.1.9
pyinotify==0.9.6
pyOpenSSL==0.15.1
PyPDF2==1.26.0
python-openid==2.2.5
repoze.lru==0.6
scgi==1.13
six==1.10.0
Tempita==0.5.2
translationstring==1.3
unity-lens-photos==1.0
venusian==1.0a8
virtualenv==15.1.0
waitress==0.8.10
WebOb==1.5.1
WebTest==2.0.18
zope.component==4.2.2
zope.deprecation==4.1.2
zope.event==4.2.0
zope.hookable==4.0.4
zope.interface==4.1.3
7
  • Do you use virtualenv? Commented May 11, 2017 at 6:45
  • When I run my project I use $ env/bin/pserve development.ini --reload, so yes Commented May 11, 2017 at 6:47
  • then instead of sudo try to install through pip Commented May 11, 2017 at 6:48
  • If you are using virtualenv, You have to install pip install PyPDF2 . If you use super user permissions it will install on the main system not in virtualenv. Commented May 11, 2017 at 6:51
  • I think you need to install pyPDF2 in your venv Commented May 11, 2017 at 6:51

2 Answers 2

1

You must install pypdf2 into your virtualenv using the pip connected to that virtualenv.

env/bin/pip install pypdf2

Anything else will install the package into the wrong environment... sudo pip install would place it into the system's site-packages, and pip install would install it into the system's site-packages but would fail because your user is not root (the only user with access to change the system's site-packages).

Sign up to request clarification or add additional context in comments.

Comments

0

I assume you created virtualenv as root . SO my suggestion is do this way:

sudo chown -R your_username:your_username path/to/virtuaelenv/

after that try to install pyPDF2 again

8 Comments

Requirement already satisfied: PyPDF2 in /usr/local/lib/python2.7/dist-packages after pip install PyPDF2
its still the same, when I run pserve development.ini it produce "bash: /usr/bin/pserve: No such file or directory"
tell me the output of pip freeze
from the command you can see you are not in your project. pip works from the system not from the virtualenv. I will suggest create a new one env without sudo and try once again.
I've managed to uninstall the PyPDF2 by sudo pip uninstall PyPDF2, and try pip freeze again, its gone now. But when I do pip install PyPDF2, same error with the above.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.