【发布时间】:2017-10-24 10:19:57
【问题描述】:
我同时使用 python Python 2.7.5 和 Python 3.4.5。但我正在使用 Python 3.4.5
此服务器上有两个用户。一位用户能够毫无问题地导入 pyodbc。但其他帐户无法访问 pyodbc 模块。
-bash-4.2$ python3
Python 3.4.5 (default, May 29 2017, 15:17:55)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyodbc
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'pyodbc'
以下是pip版本
-bash-4.2$ pip3 -V
pip 9.0.1 from /<path to lcaotion>/.local/lib/python3.4/site-packages
(python 3.4)
尝试安装pyodbc时
pip3 install pyodbc==3.0.10
遇到错误
-bash-4.2$ pip3 install pyodbc==3.0.10
Collecting pyodbc==3.0.10
Using cached pyodbc-3.0.10.tar.gz
Installing collected packages: pyodbc
Running setup.py install for pyodbc ... error
Complete output from command /usr/bin/python3.4 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-yygzbf28/pyodbc/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-4w_3g87z-record/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_ext
building 'pyodbc' extension
creating build
creating build/temp.linux-x86_64-3.4
creating build/temp.linux-x86_64-3.4/tmp
creating build/temp.linux-x86_64-3.4/tmp/pip-build-yygzbf28
creating build/temp.linux-x86_64-3.4/tmp/pip-build-yygzbf28/pyodbc
creating build/temp.linux-x86_64-3.4/tmp/pip-build-yygzbf28/pyodbc/src
gcc -pthread -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -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 -DPYODBC_VERSION=3.0.10 -DPYODBC_UNICODE_WIDTH=4 -DSQL_WCHART_CONVERT=1 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include -I/usr/include/python3.4m -c /tmp/pip-build-yygzbf28/pyodbc/src/buffer.cpp -o build/temp.linux-x86_64-3.4/tmp/pip-build-yygzbf28/pyodbc/src/buffer.o -Wno-write-strings
In file included from /tmp/pip-build-yygzbf28/pyodbc/src/buffer.cpp:12:0:
/tmp/pip-build-yygzbf28/pyodbc/src/pyodbc.h:41:20: fatal error: Python.h: No such file or directory
#include <Python.h>
^
compilation terminated.
error: command 'gcc' failed with exit status 1
以下软件包已安装在服务器中
dbus-python.x86_64
libselinux-python.x86_64
newt-python.x86_64
python.x86_64
python-backports.noarch
python-backports-ssl_match_hostname.noarch
python-configobj.noarch
python-configshell.noarch
python-decorator.noarch
python-devel.x86_64
python-ethtool.x86_64
python-iniparse.noarch
python-kmod.x86_64
python-libs.x86_64
python-pcp.x86_64
python-pycurl.x86_64
python-pyudev.noarch
python-rtslib.noarch
python-setuptools.noarch
python-slip.noarch
python-slip-dbus.noarch
python-urlgrabber.noarch
python-urwid.x86_64
python2-crypto.x86_64
python34.x86_64
python34-libs.x86_64
python34-pip.noarch
python34-setuptools.noarch
rpm-python.x86_64
而且当我尝试安装为 sudo 权限时,我得到以下信息
sudo pip3 install pyodbc==3.0.10
Requirement already satisfied: pyodbc==3.0.10 in
/export/home/python/lib/python3.4/site-packages
【问题讨论】:
标签: python-3.x pip python-import pyodbc