3

I'm new to Odoo. I use pyenv to host odoo and all the dependencies. All under odoo system user, and I was able to start odoo service:

~# systemctl status odoo-15
● odoo-15.service - Odoo15
     Loaded: loaded (/etc/systemd/system/odoo-15.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-02-18 22:33:40 UTC; 6min ago
   Main PID: 61267 (python)
      Tasks: 6 (limit: 2339)
     Memory: 79.3M
     CGroup: /system.slice/odoo-15.service
             └─61267 /home/odoo/.pyenv/versions/odoo-15-env/bin/python /home/odoo/odoo-15/odoo-bin -c /home/odoo/.odoo_config

However, the service seems always stopped somehow automatically after around 1 hour due to PyPDF2 can't find:

Feb 18 16:10:28 ubuntu-s-1vcpu-2gb-sgp1-odoo systemd[1]: Started Odoo15.
Feb 18 17:19:32 ubuntu-s-1vcpu-2gb-sgp1-odoo odoo-15[58346]: Traceback (most recent call last):
Feb 18 17:19:32 ubuntu-s-1vcpu-2gb-sgp1-odoo odoo-15[58346]:   File "/home/odoo/odoo-15/odoo-bin", line 5, in <module>
Feb 18 17:19:32 ubuntu-s-1vcpu-2gb-sgp1-odoo odoo-15[58346]:     import odoo
Feb 18 17:19:32 ubuntu-s-1vcpu-2gb-sgp1-odoo odoo-15[58346]:   File "/home/odoo/odoo-15/odoo/__init__.py", line 75, in <module>
Feb 18 17:19:32 ubuntu-s-1vcpu-2gb-sgp1-odoo odoo-15[58346]:     import PyPDF2
Feb 18 17:19:32 ubuntu-s-1vcpu-2gb-sgp1-odoo odoo-15[58346]: ModuleNotFoundError: No module named 'PyPDF2'
Feb 18 17:19:32 ubuntu-s-1vcpu-2gb-sgp1-odoo systemd[1]: odoo-15.service: Main process exited, code=exited, status=1/FAILURE
Feb 18 17:19:32 ubuntu-s-1vcpu-2gb-sgp1-odoo systemd[1]: odoo-15.service: Failed with result 'exit-code'.

But I definitely have PyPDF2 in my pyenv

odoo@ubuntu-s-1vcpu-2gb-sgp1-odoo:~/odoo-15$ python
Python 3.9.2 (default, Feb 17 2022, 17:59:57)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyPDF2
>>> PyPDF2.__version__
'1.26.0'

I feel it's something to do with my virtualenv config, but I'm bit lost here.
Could you help to enlighten me on what could be wrong here? Thank you

redpill
  • 87
  • 2
  • 8

5 Answers5

0

You need to activate virtual env and install Odoo requirements so:

sudo pip install -r requirements.txt

Or directly Install this module

pip3 install Pypdf2
DharmanBot
  • 1,066
  • 2
  • 6
  • 10
omar ahmed
  • 635
  • 5
  • 19
0

check this link , it fixed here on blogger

https://shilalg.blogspot.com/2019/07/importerror-no-module-named-pypdf2.html
Shilal
  • 46
  • 1
0

You need to activate your virtual environment and install the module within the environment, if you didn't, it won't recognize the installation.

Go to your odoo folder, as for original question

cd /home/odoo 
source odoo15-venv/bin/activate
 pip install PyPDF2  
 deactivate
 service odoo15 restart
0

As you use python3 try this command

apt-get install python3-pypdf2

-1

Usually happens when you forget to activate virtual env for odoo.

If you already have a configured virtual environment . start your venv before running odoo server.

If not . Then you have to install all the dependencies, (which are in requirement.txt file in odoo directory).

Navigate to odoo folder and run pip install -r requirements.txt. Hit enter. Let it install all packages and run your server again.

Decoy
  • 340
  • 1
  • 9