Python 3.3
,pip
已安装且PATH为:
C:\Python33\Scripts
我已下载visual c++ 2010
,是否需要更改任何配置或将.bat
文件添加到vc++
的python 33包中?
当我尝试安装pyodbc
时,我得到以下内容:
C:\Users\elyon>pip install https://pyodbc.googlecode.com/files/pyodbc-3.0.7.zip Collecting https://pyodbc.googlecode.com/files/pyodbc-3.0.7.zip Using cached https://pyodbc.googlecode.com/files/pyodbc-3.0.7.zip Installing collected packages: pyodbc Running setup.py install for pyodbc
building 'pyodbc' extension
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\elyon\appdata\local\temp\pip-30p009-build\setup.py", lin e 288, in <module>
main()
File "c:\users\elyon\appdata\local\temp\pip-30p009-build\setup.py", lin e 108, in main
setup(**kwargs)
File "C:\Python33\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Python33\lib\distutils\dist.py", line 917, in run_commands
self.run_command(cmd)
File "C:\Python33\lib\distutils\dist.py", line 936, in run_command
cmd_obj.run()
File "C:\Python33\lib\site-packages\setuptools-12.0.3-py3.3.egg\setuptools \command\install.py", line 61, in run
File "C:\Python33\lib\distutils\command\install.py", line 569, in run
self.run_command('build')
File "C:\Python33\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Python33\lib\distutils\dist.py", line 936, in run_command
cmd_obj.run()
File "C:\Python33\lib\distutils\command\build.py", line 126, in run
self.run_command(cmd_name)
File "C:\Python33\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Python33\lib\distutils\dist.py", line 936, in run_command
cmd_obj.run()
File "C:\Python33\lib\site-packages\setuptools-12.0.3-py3.3.egg\setuptools \command\build_ext.py", line 50, in run
File "C:\Python33\lib\distutils\command\build_ext.py", line 347, in run
self.build_extensions()
File "C:\Python33\lib\distutils\command\build_ext.py", line 456, in build_ extensions
self.build_extension(ext)
File "C:\Python33\lib\site-packages\setuptools-12.0.3-py3.3.egg\setuptools \command\build_ext.py", line 183, in build_extension
File "C:\Python33\lib\distutils\command\build_ext.py", line 511, in build_ extension
depends=ext.depends)
File "C:\Python33\lib\distutils\msvc9compiler.py", line 460, in compile
self.initialize()
File "C:\Python33\lib\distutils\msvc9compiler.py", line 371, in initialize
vc_env = query_vcvarsall(VERSION, plat_spec)
File "C:\Python33\lib\site-packages\setuptools-12.0.3-py3.3.egg\setuptools \msvc9_support.py", line 52, in query_vcvarsall
File "C:\Python33\lib\distutils\msvc9compiler.py", line 287, in query_vcva rsall
raise ValueError(str(list(result.keys())))
ValueError: ['path']
Complete output from command C:\Python33\python.EXE -c "import setuptools, t okenize;__file__='c:\\users\\elyon\\appdata\\local\\temp\\pip-30p009-build\\s etup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace(' \r\n', '\n'), __file__, 'exec'))" install --record c:\users\elyon\appdata\loc al\temp\pip-v0vcs5-record\install-record.txt
--single-version-externally-managed --compile:
running install
running build
running build_ext
building 'pyodbc' extension
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\elyon\appdata\local\temp\pip-30p009-build\setup.py", lin e 288, in <module>
main()
File "c:\users\elyon\appdata\local\temp\pip-30p009-build\setup.py", lin e 108, in main
setup(**kwargs)
File "C:\Python33\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Python33\lib\distutils\dist.py", line 917, in run_commands
self.run_command(cmd)
File "C:\Python33\lib\distutils\dist.py", line 936, in run_command
cmd_obj.run()
File "C:\Python33\lib\site-packages\setuptools-12.0.3-py3.3.egg\setuptools \command\install.py", line 61, in run
File "C:\Python33\lib\distutils\command\install.py", line 569, in run
self.run_command('build')
File "C:\Python33\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Python33\lib\distutils\dist.py", line 936, in run_command
cmd_obj.run()
File "C:\Python33\lib\distutils\command\build.py", line 126, in run
self.run_command(cmd_name)
File "C:\Python33\lib\distutils\cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:\Python33\lib\distutils\dist.py", line 936, in run_command
cmd_obj.run()
File "C:\Python33\lib\site-packages\setuptools-12.0.3-py3.3.egg\setuptools \command\build_ext.py", line 50, in run
File "C:\Python33\lib\distutils\command\build_ext.py", line 347, in run
self.build_extensions()
File "C:\Python33\lib\distutils\command\build_ext.py", line 456, in build_ extensions
self.build_extension(ext)
File "C:\Python33\lib\site-packages\setuptools-12.0.3-py3.3.egg\setuptools \command\build_ext.py", line 183, in build_extension
File "C:\Python33\lib\distutils\command\build_ext.py", line 511, in build_ extension
depends=ext.depends)
File "C:\Python33\lib\distutils\msvc9compiler.py", line 460, in compile
self.initialize()
File "C:\Python33\lib\distutils\msvc9compiler.py", line 371, in initialize
vc_env = query_vcvarsall(VERSION, plat_spec)
File "C:\Python33\lib\site-packages\setuptools-12.0.3-py3.3.egg\setuptools \msvc9_support.py", line 52, in query_vcvarsall
File "C:\Python33\lib\distutils\msvc9compiler.py", line 287, in query_vcva rsall
raise ValueError(str(list(result.keys())))
ValueError: ['path']
----------------------------------------
Command "C:\Python33\python.EXE -c "import setuptools, tokenize;__file__='c: \\users\\elyon\\appdata\\local\\temp\\pip-30p009-build\\setup.py';exec(compil e(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file
__, 'exec'))" install --record c:\users\elyon\appdata\local\temp\pip-v0vcs5-r ecord\install-record.txt --single-version-externally-managed
--compile" failed w ith error code 1 in
c:\users\elyon\appdata\local\temp\pip-30p009-build
这是代码:
import pyodbc
print pyodbc.dataSources()
print "Connecting via ODBC"
conn = pyodbc.connect("DRIVER={Netezza};SERVER=netezza201;PORT=5480;DATABASE=Test;UID=CompanyUser;PWD=Password!;")
cursor = conn.cursor()
答案 0 :(得分:1)
我在Python 2.7.9下使用SQLAlchemy遇到了这个问题,解决方法是在我的site-packages文件夹中解压缩pyodbc .egg文件。
我必须注意,我自己没有编译它,我下载了二进制文件(pyodbc-3.0.7.win32-py2.7.exe)并使用<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
</head>
<body ng-app="defaultValueSelect">
<div ng-controller="ExampleController">
<form name="myForm">
<label for="mySelect">Make a choice:</label>
<select name="mySelect" id="mySelect"
ng-options="option.name for option in data.availableOptions track by option.id"
ng-model="data.selectedOption"></select>
</form>
<hr>
<tt>option = {{data.selectedOption}}</tt><br/>
</div>
</body>
</html>
安装了它
P.S:可以找到更新的.whl类型安装程序here,您可以使用easy_install pyodbc-3.0.7.win32-py2.7.exe
安装它们。这也可能有助于你安装pyodbc。
导航到当前virtualenv的pip install [.whl file]
文件夹(如果您未使用virtualenv,则导航到主Python安装文件夹下)。
将\Lib\site-packages
重命名为pyodbc-3.0.7-py2.7-win32.egg
。
解压缩zip文件并将内容直接放在pyodbc-3.0.7-py2.7-win32.zip
文件夹中。
在我这样做之后,pyodbc模块被识别,SQLAlchemy可以导入它。