vuvivian's blog

越努力,越幸运.

  1. 1. 基本环境及安装软件
  2. 2. 查看环境 python 3.8报错,使用的是3.7
  3. 3. postgres数据库安装
  4. 4. 利用pycharm环境启动程序
  5. 5. 搭建环境中出现的问题及方案
    1. 5.0.1. pip安装python包出错:Could not find a version that satisfies the requirement skimage (from versions: ): Could not find a version that satisfies the requirement pywin32 (from versions: ) No matching distribution found for pywin32
    2. 5.0.2. No module named ‘psycopg2’
  6. 5.1. Database creation error: permission denied to create database
  7. 5.2. socket.error: [Errno 48] Address already in use

基本环境及安装软件

* 系统: Mac
* 开发工具:PyCharm
* 环境:node postgres python pgadmin

查看环境 python 3.8报错,使用的是3.7

* 查看当前所有Python版本: python --version  [mac自带2.7.10]
* 查看当前python路径:which python   [/usr/bin/python]

postgres数据库安装

1. 方法有二:No1.brew install postgresql ; No2:使用官网提供的Postgres.app, 下载然后拖到应用程序
2. 命令
    * 打开    wangjuan$ /Applications/Postgres.app/Contents/Versions/12/bin/psql -p5432 "postgres"
    *    修改密码 alter user postgres with password '123456';
    *    查看角色 \du
    *    创建角色 create user odoo with password 'odoo';  
    *    角色授权 alter user odoo createdb createrole;
    *    进入pgadmin连接 数据库
    *    参看资料 https://www.jianshu.com/p/fedda9824f6a

利用pycharm环境启动程序

1
2
3
4
5
6
1. 使用PyCharm打开Odoo源码
2. 添加virtualenv隔离环境,依次打开File----Setting----Project----Project Interpreter,选择安装好的Python的Python.exe路径,没有就通过右边的设置按钮添加一个新的venv环境上去,添加完成后,项目会多出一个venv文件夹,这是一个virtualenv创建的Python隔离环境,用于下载需要的第三方Python库。
3. 下载第三方Python库,如果没有提示安装需要的第三方Python库,可以打开源码下的requirements.txt,这时候应该会自动提示安装缺少的第三方Python库,安装完成后可以看到很多的第三方Python库在site-packages目录下。如果还是无法自动下载第三方库,则可以使用以下命令在根目录下运行pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple 意思是使用国内镜像将requirements文件内的第三方库下载安装(如果使用的是社区版的Pycharm,可能需要指定python命令的具体路径,并且使用–target指定下载的库位置,具体位置是你新建的venv位置,否则会使用系统安装的python命令以及安装到该处)
* wkhtmltopdf,按照官网文档,如果要导出pdf文件,需要安装wkhtmltopdf,安装完需要配置环境变量,在系统变量path中添加wkhtmltopdf的bin路径,否则无法使用,下载地址https://wkhtmltopdf.org/downloads.html
4. 启动程序
5. 报错的话查看并修改congif文件:/odoo-13.0/debian/odoo.conf
1
2
3
4
5
6
7
[options]
admin_passwd = admin
db_host=localhost
db_port=5432
db_user=odoo
db_password=odoo
addons_path=/odoo-13.0/addons

搭建环境中出现的问题及方案

pip安装python包出错:Could not find a version that satisfies the requirement skimage (from versions: ): Could not find a version that satisfies the requirement pywin32 (from versions: ) No matching distribution found for pywin32

解决方案:这是因为网络的问题,需要使用国内的镜像源来加速,比如豆瓣源
命令改为:
pip install scikit-image -i http://pypi.douban.com/simple/ –trusted-host pypi.douban.com
或者
pip3 install scikit-image -i http://pypi.douban.com/simple/ –trusted-host pypi.douban.com
最后成功安装:

No module named ‘psycopg2’
解决方案:使用psycopg2-binary(已经编译好的,包含各种依赖的),跳过手动编译阶段 :
    pip install psycopg2-binary

Database creation error: permission denied to create database

解决方案:给角色赋权:CREATE ROLE odoo WITH SUPERUSER LOGIN PASSWORD ‘odoo’;

socket.error: [Errno 48] Address already in use

解决方案: 1. sudo lsof -i:8069 2. kill {PID}

本文最后更新于 天前,文中所描述的信息可能已发生改变