IAM-SERVICE初始数据遇到了问题

自动配置完成了
python3 ../../choerodon-front/node_modules/choerodon-front-boot/structure/configAuto.py iam

无法执行下面这句,看起来是python需要有2和3 2个版本同时存在,系统是MACOS

python ../../choerodon-front/node_modules/choerodon-front-boot/structure/sql.py

报错如下

Traceback (most recent call last):

File "../../choerodon-front/node_modules/choerodon-front-boot/structure/sql.py", line 4, in <module>

import yaml

ImportError: No module named yaml

又通过

 pip install pyyaml
 pip install pymysql

安装sql.py里面所需的组件,最后显示安装完成,还是报出无法找到模块yaml

请大大帮忙看看,感谢

pip install pyyaml

Requirement already satisfied: pyyaml in /usr/local/lib/python2.7/site-packages (3.13)


pip install pymysql

Requirement already satisfied: pymysql in /usr/local/lib/python2.7/site-packages (0.9.2)

Requirement already satisfied: cryptography in /usr/local/lib/python2.7/site-packages (from pymysql) (2.3.1)

Requirement already satisfied: enum34; python_version < "3" in /usr/local/lib/python2.7/site-packages (from cryptography->pymysql) (1.1.6)

Requirement already satisfied: asn1crypto>=0.21.0 in /usr/local/lib/python2.7/site-packages (from cryptography->pymysql) (0.24.0)

Requirement already satisfied: cffi!=1.11.3,>=1.7 in /usr/local/lib/python2.7/site-packages (from cryptography->pymysql) (1.11.5)

Requirement already satisfied: idna>=2.1 in /usr/local/lib/python2.7/site-packages (from cryptography->pymysql) (2.7)

Requirement already satisfied: six>=1.4.1 in /usr/local/lib/python2.7/site-packages (from cryptography->pymysql) (1.11.0)

Requirement already satisfied: ipaddress; python_version < "3" in /usr/local/lib/python2.7/site-packages (from cryptography->pymysql) (1.0.22)

Requirement already satisfied: pycparser in /usr/local/lib/python2.7/site-packages (from cffi!=1.11.3,>=1.7->cryptography->pymysql) (2.19)

补充一下环境信息:


william:choerodon-front-iam will$ python --version
Python 2.7.10
william:choerodon-front-iam will$ pip --version
pip 18.0 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)
william:choerodon-front-iam will$ 
william:choerodon-front-iam will$ 
william:choerodon-front-iam will$ python3 --version
Python 3.7.0
william:choerodon-front-iam will$ pip3 --version
pip 18.0 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)

你好,麻烦提供下如下信息:

  • choerodon-front-boot 版本
  • 操作系统版本
  • python 版本

同时安装了python2 和python3? 如果同时都安装的话,建议将python3卸载掉重新试下。菜单初始化的脚本不支持python3

choerodon-front-boot 是通过拉取
github master  choerodon-front
OS MacOS 10.13.6 (17G65)

PYTHON 的相关版本如下:

william:choerodon-front-iam will$ python --version
Python 2.7.10
william:choerodon-front-iam will$ pip --version
pip 18.0 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)
william:choerodon-front-iam will$ 
william:choerodon-front-iam will$ 
william:choerodon-front-iam will$ python3 --version
Python 3.7.0
william:choerodon-front-iam will$ pip3 --version
pip 18.0 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)

但是我看到autoConfig.py里面定义的是3的版本,所以就去装了个3的版本

#!/usr/bin/python3

格式排得不太好,请见谅一下哈。

这个是我们代码的问题,我们修改下,感谢反馈

太帅了,这么快的响应

我刚才换成了 2.7 版本的python 出现了新的情况
brew install python@2

pip install pymysql
pip install pyyaml

 python --version
pPython 2.7.10
pip --version
pip 18.0 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)


python ../../choerodon-front/node_modules/choerodon-front-boot/structure/sql.py
Traceback (most recent call last):
  File "../../choerodon-front/node_modules/choerodon-front-boot/structure/sql.py", line 4, in <module>
    import yaml
  File "/usr/local/lib/python2.7/site-packages/yaml/__init__.py", line 8, in <module>
    from loader import *
  File "/usr/local/lib/python2.7/site-packages/yaml/loader.py", line 4, in <module>
    from reader import *
  File "/usr/local/lib/python2.7/site-packages/yaml/reader.py", line 45, in <module>
    class Reader(object):
  File "/usr/local/lib/python2.7/site-packages/yaml/reader.py", line 137, in Reader
    NON_PRINTABLE = re.compile(u'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD]')
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 194, in compile
    return _compile(pattern, flags)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py", line 249, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_compile.py", line 576, in compile
    code = _code(p, flags)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_compile.py", line 558, in _code
    _compile_info(code, p, flags)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_compile.py", line 536, in _compile_info
    _compile_charset(charset, flags, code)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_compile.py", line 232, in _compile_charset
    flags & SRE_FLAG_UNICODE):
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_compile.py", line 386, in _optimize_charset
    data[0:0] = [block] + _bytes_to_codes(mapping)
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_compile.py", line 418, in _bytes_to_codes
    import array
ImportError: dlopen(/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/array.so, 2): Symbol not found: __PySlice_AdjustIndices
  Referenced from: /usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/array.so
  Expected in: flat namespace
 in /usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/array.so

如果我使用刚才安装的python2 则是另一个错误出现了


python2 ../../choerodon-front/node_modules/choerodon-front-boot/structure/sql.py
Traceback (most recent call last):
  File "../../choerodon-front/node_modules/choerodon-front-boot/structure/sql.py", line 72, in insertMenuTable
    if judgeTrue(table, 'code', root, 'level', levelYaml):
  File "../../choerodon-front/node_modules/choerodon-front-boot/structure/sql.py", line 31, in judgeTrue
    cursor.execute(sql)
  File "/usr/local/lib/python2.7/site-packages/pymysql/cursors.py", line 170, in execute
    result = self._query(query)
  File "/usr/local/lib/python2.7/site-packages/pymysql/cursors.py", line 328, in _query
    conn.query(q)
  File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 516, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 727, in _read_query_result
    result.read()
  File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 1066, in read
    first_packet = self.connection._read_packet()
  File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 683, in _read_packet
    packet.check_error()
  File "/usr/local/lib/python2.7/site-packages/pymysql/protocol.py", line 220, in check_error
    err.raise_mysql_exception(self._data)
  File "/usr/local/lib/python2.7/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
    raise errorclass(errno, errval)
InternalError: (1054, u"Unknown column 'level' in 'where clause'")
Traceback (most recent call last):
  File "../../choerodon-front/node_modules/choerodon-front-boot/structure/sql.py", line 178, in insertMenuTlTable
    menuId = returnMenuId('iam_menu', menuList, level)
  File "../../choerodon-front/node_modules/choerodon-front-boot/structure/sql.py", line 14, in returnMenuId
    cursor.execute(sql)
  File "/usr/local/lib/python2.7/site-packages/pymysql/cursors.py", line 170, in execute
    result = self._query(query)
  File "/usr/local/lib/python2.7/site-packages/pymysql/cursors.py", line 328, in _query
    conn.query(q)
  File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 516, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 727, in _read_query_result
    result.read()
  File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 1066, in read
    first_packet = self.connection._read_packet()
  File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 683, in _read_packet
    packet.check_error()
  File "/usr/local/lib/python2.7/site-packages/pymysql/protocol.py", line 220, in check_error
    err.raise_mysql_exception(self._data)
  File "/usr/local/lib/python2.7/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
    raise errorclass(errno, errval)
InternalError: (1054, u"Unknown column 'level' in 'where clause'")
Traceback (most recent call last):
  File "../../choerodon-front/node_modules/choerodon-front-boot/structure/sql.py", line 203, in insertServiceTlTable
    count = cursor.execute(sql)
  File "/usr/local/lib/python2.7/site-packages/pymysql/cursors.py", line 170, in execute
    result = self._query(query)
  File "/usr/local/lib/python2.7/site-packages/pymysql/cursors.py", line 328, in _query
    conn.query(q)
  File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 516, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 727, in _read_query_result
    result.read()
  File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 1066, in read
    first_packet = self.connection._read_packet()
  File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 683, in _read_packet
    packet.check_error()
  File "/usr/local/lib/python2.7/site-packages/pymysql/protocol.py", line 220, in check_error
    err.raise_mysql_exception(self._data)
  File "/usr/local/lib/python2.7/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
    raise errorclass(errno, errval)
InternalError: (1054, u"Unknown column 'level' in 'where clause'")
Traceback (most recent call last):
  File "../../choerodon-front/node_modules/choerodon-front-boot/structure/sql.py", line 151, in insertMenuPermission
    menuId = returnMenuId('iam_menu', menuList, level)
  File "../../choerodon-front/node_modules/choerodon-front-boot/structure/sql.py", line 14, in returnMenuId
    cursor.execute(sql)
  File "/usr/local/lib/python2.7/site-packages/pymysql/cursors.py", line 170, in execute
    result = self._query(query)
  File "/usr/local/lib/python2.7/site-packages/pymysql/cursors.py", line 328, in _query
    conn.query(q)
  File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 516, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 727, in _read_query_result
    result.read()
  File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 1066, in read
    first_packet = self.connection._read_packet()
  File "/usr/local/lib/python2.7/site-packages/pymysql/connections.py", line 683, in _read_packet
    packet.check_error()
  File "/usr/local/lib/python2.7/site-packages/pymysql/protocol.py", line 220, in check_error
    err.raise_mysql_exception(self._data)
  File "/usr/local/lib/python2.7/site-packages/pymysql/err.py", line 109, in raise_mysql_exception
    raise errorclass(errno, errval)
InternalError: (1054, u"Unknown column 'level' in 'where clause'")

这里就只有一个小问题,我修复过程如下:

临时修改数据库字段名 FD_LEVEL 为 LEVEL
执行脚本
再将字段名改回为 FD_LEVEL

因为master 分支的代码是我们最新的代码,我们数据库有做过修改。建议使用tag 对应的代码

OK 谢谢你