简体   繁体   English

Odoo 11:ImportError 没有名为“PyPDF2”的模块

[英]Odoo 11 : ImportError No Module Named 'PyPDF2'

I'm using a script to run Odoo11 via pycharm in ubuntu (openerp_openserver script)我正在使用脚本在 ubuntu 中通过 pycharm 运行 Odoo11(openerp_openserver 脚本)

脚本

When i try to run the program , it fails at some point , when it import pdf module and i have this error :当我尝试运行该程序时,它在某个时候失败了,当它导入 pdf 模块时出现此错误:

ImportError No Module Named 'PyPDF2' as you can see in this Image ImportError No Module Named 'PyPDF2'如您在此图像中所见

在此处输入图片说明

I Already installed PyPDF2 via this command (i have python3.5 already installed) :我已经通过这个命令安装了 PyPDF2(我已经安装了 python3.5):

sudo apt-get install python3-pypdf2

在此处输入图片说明

So im wondering , what is the problem , why pycharm cannot find and import pypdf2?所以我想知道,有什么问题,为什么 pycharm 找不到并导入 pypdf2?

Thanks谢谢

EDIT :编辑 :

When i Try to import PyPDF2 using the Python command , i dont have error当我尝试使用 Python 命令导入 PyPDF2 时,我没有错误在此处输入图片说明

Firstly you should try to check whether you can import PyPDF2 library from a python console.首先,您应该尝试检查是否可以从 python 控制台导入 PyPDF2 库。

Run from your native console:从您的本机控制台运行:

python3 -c "import PyPDF2"

If no error message occurs, the problem is not in the library.如果没有出现错误消息,则问题不在库中。

Check a path of python interpreter that is used by PyCharm.检查 PyCharm 使用的 python 解释器的路径。

Navigate inside PyCharm:在 PyCharm 中导航:

Ctrl-Alt-S > Build, Execution Deployment > Console > Python Console

The path should be to /usr/bin/ folder.路径应该是/usr/bin/文件夹。

If not - change it to a path of the desirable python interpreter that is inside /usr/bin/ folder.如果不是 - 将其更改为/usr/bin/文件夹内所需的 python 解释器的路径。

I hope this helps!我希望这有帮助!

Will be good if someone can add a way to solve this type of problem in Windows environment.如果有人可以添加一种方法来解决 Windows 环境中的此类问题,那就太好了。

对于 Windows,您可以尝试为 venv(虚拟环境)再次安装 psycopg2 和要求。对于 psycopg2 安装,您应该按照http://www.stickpeople.com/projects/python/win-psycopg/上“虚拟环境安装说明”标题下的步骤进行操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM