如何在ipython中安装pyodbc [英] How to install pyodbc to be used in ipython

查看:141
本文介绍了如何在ipython中安装pyodbc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很困惑。我已经在我的计算机上安装了pyodbc,我可以使用其他IDE
导入它,但我是ipython的新手。

I'm confused. I have installed pyodbc on my computer and I was able to import it using other IDE but i'm new to ipython.

我使用Ananconda,并且可以使用像

I use Ananconda , and was able to install other library using something like

pip install BeautifulSoup

但是当我使用pyodbc使用

But when I do that with pyodbc using

pip install pyodbc

I得到错误:

error: command 'gcc' failed with exist status 1






C:\ Users \ jeannie.chirayu> pip install pyodbc
下载/解包pyodbc
您正在安装可能不安全且无法验证的文件。 pip的未来版本
ns将默认禁止不安全的文件。
下载pyodbc-3.0.7.zip(85kB):85kB下载
运行setup.py egg_info包pyodbc


C:\Users\jeannie.chirayu>pip install pyodbc Downloading/unpacking pyodbc You are installing a potentially insecure and unverifiable file. Future versio ns of pip will default to disallowing insecure files. Downloading pyodbc-3.0.7.zip (85kB): 85kB downloaded Running setup.py egg_info for package pyodbc

warning: no files found matching 'tests\*'

安装收集的软件包:pyodbc
为pyodbc运行setup.py安装
构建'pyodbc'扩展名
C:\Anaconda \Scripts\gcc.bat -DMS_WIN64 -mdll -O -Wall -DPYODBC_VERSION = 3.0。 7
-IC:\ Anaconda \include -IC:\ Anaconda \ PC -cc:\ usersrs \ jeanni~1.chi \ appdata \ local \ t
\\ temp \ _pip_build_jeannie.chirayu\pyodbc\src\buffer.cpp -oc:\ usersrs \ jeanni~1.chi\app
data \ local \ temp\pip_build_jeannie.chirayu \ pyodbc\src\buffer.o / Wall / wd4668 / wd4
820 / wd4711 / wd4100 / wd4127 / wd4191
gcc.exe:错误:/ Wall:没有这样的文件或目录
gcc.exe:错误:/ wd4668:没有这样的文件或目录
gcc.exe:错误: / wd4820:没有这样的文件或目录
gcc.exe:错误:/ wd4711:没有这样的文件或目录
gcc.exe:错误:/ wd4100:没有这样的文件或目录
gcc。 exe:错误:/ wd4127:没有这样的文件或目录
gcc.exe:错误:/ wd4191:没有这样的文件或目录
错误:命令'gcc'失败,退出状态1
完成从命令C输出:\ Anaconda \ python.exe -cimport setuptools; __
file __ ='c:\ usersrs \ jeanni~1.chi \ appdata\local \ temp \ pip_build_jeannie.chirayu
\pyodbc \setup.py'; exec(编译(打开(文件)。read()。replace('\\ n','\\ \\ n'),__
file _,'exec'))install --record c:\users\jeanni~1.chi \ appdata\local \ temp \ pip-
lqnyba-record \ install-record.txt --single-version-external-managed:
运行安装

Installing collected packages: pyodbc Running setup.py install for pyodbc building 'pyodbc' extension C:\Anaconda\Scripts\gcc.bat -DMS_WIN64 -mdll -O -Wall -DPYODBC_VERSION=3.0.7 -IC:\Anaconda\include -IC:\Anaconda\PC -c c:\users\jeanni~1.chi\appdata\local\t emp\pip_build_jeannie.chirayu\pyodbc\src\buffer.cpp -o c:\users\jeanni~1.chi\app data\local\temp\pip_build_jeannie.chirayu\pyodbc\src\buffer.o /Wall /wd4668 /wd4 820 /wd4711 /wd4100 /wd4127 /wd4191 gcc.exe: error: /Wall: No such file or directory gcc.exe: error: /wd4668: No such file or directory gcc.exe: error: /wd4820: No such file or directory gcc.exe: error: /wd4711: No such file or directory gcc.exe: error: /wd4100: No such file or directory gcc.exe: error: /wd4127: No such file or directory gcc.exe: error: /wd4191: No such file or directory error: command 'gcc' failed with exit status 1 Complete output from command C:\Anaconda\python.exe -c "import setuptools;__ file__='c:\users\jeanni~1.chi\appdata\local\temp\pip_build_jeannie.chirayu \pyodbc\setup.py';exec(compile(open(file).read().replace('\r\n', '\n'), __ file__, 'exec'))" install --record c:\users\jeanni~1.chi\appdata\local\temp\pip- lqnyba-record\install-record.txt --single-version-externally-managed: running install

运行构建

运行build_ext

running build_ext

建设'py odbc'扩展

building 'pyodbc' extension

C:\ Anaconda \Scripts\gcc.bat -DMS_WIN64 -mdll -O -Wall -DPYODBC_VERSION = 3.0.7 -IC
:\ Anaconda \include -IC:\ Anaconda \ PC -cc:\ usersrs \ jeanni~1.chi \ appdata\local \ temp \
pip_build_jeannie.chirayu \ pyodbc\src\buffer.cpp -oc:\ usersrs \ jeanni~1.chi \ appdata
\ local \ temp\pip_build_jeannie.chirayu \ pyodbc\src\buffer。 o / Wall / wd4668 / wd4820
/ wd4711 / wd4100 / wd4127 / wd4191

C:\Anaconda\Scripts\gcc.bat -DMS_WIN64 -mdll -O -Wall -DPYODBC_VERSION=3.0.7 -IC :\Anaconda\include -IC:\Anaconda\PC -c c:\users\jeanni~1.chi\appdata\local\temp\ pip_build_jeannie.chirayu\pyodbc\src\buffer.cpp -o c:\users\jeanni~1.chi\appdata \local\temp\pip_build_jeannie.chirayu\pyodbc\src\buffer.o /Wall /wd4668 /wd4820 /wd4711 /wd4100 /wd4127 /wd4191

gcc.exe:错误:/ Wall:没有这样的文件或目录

gcc.exe: error: /Wall: No such file or directory

gcc.exe:错误:/ wd4668:没有这样的文件或目录

gcc.exe: error: /wd4668: No such file or directory

gcc.exe:错误:/ wd4820 :没有这样的文件或目录

gcc.exe: error: /wd4820: No such file or directory

gcc.exe:错误:/ wd4711:没有这样的文件或目录

gcc.exe: error: /wd4711: No such file or directory

gcc.exe:错误:/ wd4100:没有这样的文件或目录

gcc.exe: error: /wd4100: No such file or directory

gcc.exe:错误:/ wd4127:没有这样的文件或目录

gcc.exe: error: /wd4127: No such file or directory

gcc.exe:错误:/ wd4191:没有这样的f ile或目录

gcc.exe: error: /wd4191: No such file or directory

错误:命令'gcc'失败,退出状态为1

error: command 'gcc' failed with exit status 1

清理...
命令C:\ Anaconda\python.exe -cimport setuptools; file ='c:\ usersrs \ jeanni
~1.chi\appdata\local\temp\pip_build_jeannie.chirayu\pyodbc\setup.py'; exec(
compile(open( file )) .read()。replace('\\ n','\ n'),文件,'exec'))安装
- 记录c:\ users\jeanni~1.chi\appdata\local\temp\pip-lqnyba-record\install-rec
ord.txt --single-version-external-managed失败,错误代码为1在c:\ usersrs
\ jeanni~1.chi \ appdata\local \ temp \ pip_build_jeannie.chirayu \ pyodbc
存储完整的登录C:\ Users \ j \ pip \ pip.log

Cleaning up... Command C:\Anaconda\python.exe -c "import setuptools;file='c:\users\jeanni ~1.chi\appdata\local\temp\pip_build_jeannie.chirayu\pyodbc\setup.py';exec( compile(open(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record c:\users\jeanni~1.chi\appdata\local\temp\pip-lqnyba-record\install-rec ord.txt --single-version-externally-managed failed with error code 1 in c:\users \jeanni~1.chi\appdata\local\temp\pip_build_jeannie.chirayu\pyodbc Storing complete log in C:\Users\j\pip\pip.log

任何建议都会有所帮助。谢谢。

Any recommendation would help. Thanks.

推荐答案

这很烦人。但我得到了它的工作。基本上,pyodbc源代码缺少很多废话。

this was annoying. but i got it working. basically, pyodbc source code is missing a lot of crap.

1)在pyodbc目录中,打开setup.py并搜索wd4668。

1) in the pyodbc directory, open setup.py and search for "wd4668".

将该列表更改为:

settings['extra_compile_args'] = []

2)在src目录中,创建一个名为abc_minmax.h的文件。在其中,放:

2) in the src directory, create a file called "abc_minmax.h". in it, put:

#ifndef min 

#define min(a, b) ((a < b) ? a : b)
#define max(a, b) ((a > b) ? a : b)

#endif

3)在src目录的以下文件中:

3) in the following files in the src directory:

cursor.h
params.h
sqlwchar.h

在顶部的其他包含附近添加以下行:

add the following line near the other includes at the top:

#include "abc_minmax.h"

4)最后,在文件wrapper.h中,在其他包含附近添加以下2行:

4) finally, in the file wrapper.h, add the following 2 lines near the other includes:

#include <Windows.h>
#include <Winreg.h>

好的,应该这样做!如果有什么不起作用,请告诉我。

ok, that should do it! let me know if something doesn't work.

这篇关于如何在ipython中安装pyodbc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆