Linux搭建python环境详解

2019-10-13 11:25:30王振洲

2、在python运行过程中出现如下错误:

python错误:ImportError: No module named setuptools

这句错误提示的表面意思是:没有setuptools的模块,说明python缺少这个模块,那我们只要安装这个 模块即可解决此问题

解决方法:安装setuptools

3、执行python脚本时,报错

[root@vm4 statistics]# Python-2.7.3 generator.py

Traceback (most recent call last): File "generator.py", line 3, in <module>

import cx_Oracle

ImportError: No module named cx_Oracle

解决方法:安装cx_Oracle

4、[root@localhost site-packages]# pip install cx_Oracle报错:

Downloading/unpacking cx-Oracle

Downloading cx_Oracle-5.1.3.tar.gz (104kB): 104kB downloaded

Running setup.py (path:/tmp/pip_build_root/cx-Oracle/setup.py) egg_info for package cx-Oracle

Installing collected packages: cx-Oracle

Running setup.py install for cx-Oracle

building 'cx_Oracle' extension

gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/opt/oracle/instantclient_11_2/sdk/include -I/usr/include/python2.6 -c cx_Oracle.c -o build/temp.linux-x86_64-2.6-11g/cx_Oracle.o -DBUILD_VERSION=5.1.3

gcc -pthread -shared build/temp.linux-x86_64-2.6-11g/cx_Oracle.o -L/opt/oracle/instantclient_11_2/ -L/usr/lib64 -lclntsh -lpython2.6 -o build/lib.linux-x86_64-2.6-11g/cx_Oracle.so

/usr/bin/ld: cannot find -lclntsh

collect2: ld returned 1 exit status

error: command 'gcc' failed with exit status 1

Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/cx-Oracle/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('rn', 'n'), __file__, 'exec'))" install --record /tmp/pip-ONXD3d-record/install-record.txt --single-version-externally-managed --compile:

running install

running build

running build_ext

building 'cx_Oracle' extension

creating build

creating build/temp.linux-x86_64-2.6-11g

gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/opt/oracle/instantclient_11_2/sdk/include -I/usr/include/python2.6 -c cx_Oracle.c -o build/temp.linux-x86_64-2.6-11g/cx_Oracle.o -DBUILD_VERSION=5.1.3

creating build/lib.linux-x86_64-2.6-11g

gcc -pthread -shared build/temp.linux-x86_64-2.6-11g/cx_Oracle.o -L/opt/oracle/instantclient_11_2/ -L/usr/lib64 -lclntsh -lpython2.6 -o build/lib.linux-x86_64-2.6-11g/cx_Oracle.so