首页 > 编程语言 >安装dmPython

安装dmPython

时间:2024-01-29 20:24:24浏览次数:34  
标签:python 安装 py install dm8 root dmPython

一、安装dmPython

对于达梦数据库,必须首先安装dmPython,才可以使用,在$DM_HOME/drivers 目录下有多种类型的驱动:

[dmdba@dm8 ~]$ cd /dm/dmdbms/drivers/
[dmdba@dm8 drivers]$ ls
dci  dotNet  dpi  fldr  go  jdbc  logmnr  msgparse  odbc  php_pdo  python  r2dbc


[dmdba@dm8 drivers]$ cd python/
[dmdba@dm8 python]$ ls
django_dmPython2.0.0  django_dmPython3.0.0  dmPython  sqlalchemy  sqlalchemy1.4.6  sqlalchemy2.0.0

[dmdba@dm8 python]$ cd dmPython/
[dmdba@dm8 dmPython]$ ls
Buffer.c  Connection.c  Environment.c  Error.h    exLob.c     py_Dameng.c  README.txt  row.h     strct.h    trc.c  var.c      vBfile.c   vDateTime.c  vLob.c   vNumber.c  vString.c  Buffer.h  Cursor.c      Error.c        exBfile.c  exObject.c  py_Dameng.h  row.c       setup.py  tObject.c  trc.h  var_pub.h  vCursor.c  vInterval.c  vlong.c  vObject.c

这里我们需要手工安装dmPython 包。进入dmPython目录后执行命令:

python setup.py install

命令虽简单,但过程插曲比较多。

1、插曲一:权限问题Permission denied

开始使用dmdba 用户执行,报如下错误:

[dmdba@dm8 dmPython]$ python setup.py install
running install
error: can't create or remove files in install directory

[dmdba@dm8 dmPython]$ su
# 输入root密码
[root@dm8 ~]# 

2、 插曲二: cannot locate an Dameng software installation

切换成root用户执行,又报如下错误:

[root@dm8 ~]# cd /dm/dmdbms/drivers/python/dmPython
[root@dm8 dmPython]# python setup.py install
Traceback (most recent call last):
  File "setup.py", line 103, in <module>
    raise DistutilsSetupError("cannot locate an Dameng software " /
distutils.errors.DistutilsSetupError: cannot locate an Dameng software installation
[root@dm8 dmPython]#

因为安装依赖DM的环境,这里在root用户下配置dm的环境变量

[root@dm8 dmPython]# cat ~/.bash_profile
# .bash_profile
 
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi
 
# User specific environment and startup programs
 
PATH=$PATH:$HOME/bin
 
export PATH
export PATH="/dm/dmdbms/bin:$PATH"
export DM_HOME="/dm/dmdbms"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/dm/dmdbms/bin"

[root@dm8 dmPython]# source ~/.bash_profile

3 、插曲三:unable to execute gcc: No such file or directory

解决上面的问题后继续安装:

[root@dm8 dmPython]# python setup.py  install
running install
……

building 'dmPython' extension
creating build
creating build/temp.linux-x86_64-2.7
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DDM64 -I/dm/dmdbms/include -I/usr/include/python2.7 -c py_Dameng.c -o build/temp.linux-x86_64-2.7/py_Dameng.o -DBUILD_VERSION=2.3
unable to execute gcc: No such file or directory
error: command 'gcc' failed with exit status 1
[root@dm8 dmPython]#


# 提示缺少gcc 包,直接yum 安装:

[root@dm8 dmPython]# yum install gcc* -y
4、插曲四:py_Dameng.h:8:20: fatal error: Python.h: No such file or directory

解决gcc 包之后继续安装:

[root@dm8 dmPython]# python setup.py  install
running install
……

building 'dmPython' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DDM64 -I/dm/dmdbms/include -I/usr/include/python2.7 -c py_Dameng.c -o build/temp.linux-x86_64-2.7/py_Dameng.o -DBUILD_VERSION=2.3
In file included from py_Dameng.c:3:0:
py_Dameng.h:8:20: fatal error: Python.h: No such file or directory
 #include <Python.h>
                    ^
compilation terminated.
error: command 'gcc' failed with exit status 1
[root@dm8 dmPython]#

# 这里是缺少python-devel 包,老方法,直接yum 解决:

[root@dm8 dmPython]# yum install python-devel

最后终于安装成功:

[root@dm8 dmPython]# python setup.py install
……
creating dist
creating 'dist/dmPython-2.3-py2.7-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing dmPython-2.3-py2.7-linux-x86_64.egg
Copying dmPython-2.3-py2.7-linux-x86_64.egg to /usr/lib64/python2.7/site-packages
Adding dmPython 2.3 to easy-install.pth file
 
Installed /usr/lib64/python2.7/site-packages/dmPython-2.3-py2.7-linux-x86_64.egg
Processing dependencies for dmPython==2.3
Finished processing dependencies for dmPython==2.3
[root@dm8 dmPython]#

二、测试dmPython

[root@dm8 dmPython]# python
Python 2.7.5 (default, Feb 20 2018, 09:19:12) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

# 测试代码(更换成自己的达梦配置)
>>> 
import dmPython
conn=dmPython.connect(user='SYSDBA',password='SYSDBA',server= '192.168.201.118',port=5236)
cursor = conn.cursor()
cursor.execute('select username from dba_users')
values = cursor.fetchall()
print(values)
cursor.close()
conn.close()

image-20240103211559235

输出数据库中的用户名则表示连接数据库成功。

https://eco.dameng.com/document/dm/zh-cn/start/python-development.html

标签:python,安装,py,install,dm8,root,dmPython
From: https://www.cnblogs.com/DQ-MINE/p/17995251

相关文章

  • 在内网(不通公网)的情况下,使用pip安装python依赖包
    1.施工服务器后端部署一:准备一台环境与内网虚拟机相同的可以连接外网的虚拟机,python版本,操作系统版本保持一致二:在可以链接外网的机器上使用pip将依赖包的whl文件(也有可能是tar.gz或者tar格式,不过不影响后续使用)#将依赖下载到本地的某个文件中root@iZ8v2rbZ:/sdwork/pyyl#......
  • kubeadm安装Kubernetes集群踩坑笔记
    目录背景步骤一安装DockerEngine步骤二:安装前配置步骤三:安装kubeadm步骤四:安装kubernetes的Master节点镜像准备开始安装安装Flannel网络插件步骤五:安装kubernetes的Worker节点总结思考背景最近在极客时间上跟Chrono大神学习Kubernetes基础,在实践过程中遇到一些运维、使用方面......
  • AirSim安装与项目初始化
    AirSim与UnrealEngine的安装见https://zhuanlan.zhihu.com/p/618440744在安装的时候版本选择UE4.27与Visualstudio2022。在每个UEproject中,都存在一个.project文件,通过vscode打开则在里面可以设置打开方式,通过修改EngineAssociation可以设置用哪个版本的UE引擎打开该文件。......
  • gitlab-runner helm 安装问题记录
      首先说说安装步骤1、安装版本gitlab-runner-0.36.1.tgz  cat./gitlab-runner/values.yaml|grep-v"#"|sed-e'/^$/d'imagePullPolicy:IfNotPresentgitlabUrl:http://101.43.196.155:32080/runnerRegistrationToken:"Woq_Drxy-SSy1kQzJBZT&......
  • windows下为php安装event扩展,失败原因,最终成功
    PHP:在Windows上安装PHP扩展-ManualPECL::Package::event(php.net)windows安装phpevent扩展问题_windowsenevt扩展步骤-CSDN博客 最开始不懂,以为还要安装libevent--不是,只要event就好了后来以为安装的扩展版本不对--按照phpinfo下载的,是对的全网只有一个地方......
  • vue安装node-sass sass-loader 报错
    vue安装node-sass  sass-loader报错 主要的原因是因为node的版本 和  node-sass  sass-loader 不匹配导致的报错node-sass版本和sass-loader版本对应 具体查看这个链接   https://www.npmjs.com/package/node-sass拿我当前项目举例  我node版本是16......
  • 迅为3588开发板Ubuntu安装Docker
      在使用迅为RK3588开发板的时候,我们一般采用的是虚拟机安装Ubuntu20.04来编译Android源码或者linux源码,但是编译源码最让人头疼的是主机环境问题。假如我手上有很多块开发板,每个开发板都使用不同的编译环境,而我本地电脑已经有一个编译环境了,那怎么办呢?  有没......
  • Windows下安装和配置Java JDK
    1、......
  • Windows安装MySql时出现“Failed to find valid data directory”的错误
    1、......
  • VMware - Windows 10 1909 Version 安装
    (注意:使用VMwareworkstation16pro安装windows10的22h2版本可能失败,需要回滚到1909Version即可)VMware虚拟机软件:我使用的VMware版本是VMwareWorkstation16Pro,官网下载试用WindowsISO:版本是cn_windows_10_consumer_editions_version_1909_updated_jan_2020_x64_dvd_4......