在 Windows 10 上安装 pymssql 时出错
Posted
技术标签:
【中文标题】在 Windows 10 上安装 pymssql 时出错【英文标题】:Error while installing pymssql on windows 10 【发布时间】:2018-01-07 07:56:22 【问题描述】:我收到“系统找不到指定的路径”错误。
谁能给我一些关于如何使路径正确的提示?
我在使用 pip 时从未遇到过此类错误。
C:\Users\ahkim>pip install pymssql
Collecting pymssql
Downloading pymssql-2.1.3.tar.gz (897kB)
100% |████████████████████████████████| 901kB 1.9MB/s
Building wheels for collected packages: pymssql
Running setup.py bdist_wheel for pymssql ... error
Complete output from command C:\Users\ahkim\AppData\Local\Continuum\anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\ahkim\\AppData\\Local\\Temp\\pip-build-mfok55b5\\pymssql\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\ahkim\AppData\Local\Temp\tmp127kpd9epip-wheel- --python-tag cp36:
setup.py: platform.system() => 'Windows'
setup.py: platform.architecture() => ('64bit', 'WindowsPE')
running bdist_wheel
running build
running build_ext
building '_mssql' extension
error: [WinError 3] The system cannot find the path specified: 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\PlatformSDK\\lib'
----------------------------------------
Failed building wheel for pymssql
Running setup.py clean for pymssql
Failed to build pymssql
Installing collected packages: pymssql
Running setup.py install for pymssql ... error
Complete output from command C:\Users\ahkim\AppData\Local\Continuum\anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\ahkim\\AppData\\Local\\Temp\\pip-build-mfok55b5\\pymssql\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\ahkim\AppData\Local\Temp\pip-r247wrkl-record\install-record.txt --single-version-externally-managed --compile:
setup.py: platform.system() => 'Windows'
setup.py: platform.architecture() => ('64bit', 'WindowsPE')
running install
running build
running build_ext
cythoning _mssql.pyx to _mssql.c
warning: _mssql.pyx:143:4: Exception already a builtin Cython type
building '_mssql' extension
error: [WinError 3] The system cannot find the path specified: 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\PlatformSDK\\lib'
----------------------------------------
Command "C:\Users\ahkim\AppData\Local\Continuum\anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\ahkim\\AppData\\Local\\Temp\\pip-build-mfok55b5\\pymssql\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\ahkim\AppData\Local\Temp\pip-r247wrkl-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\ahkim\AppData\Local\Temp\pip-build-mfok55b5\pymssql\
【问题讨论】:
pymssql 2.1.3 为 Python 3.5 预先构建了 wheel 文件,因此 pip 会尝试从源代码构建它很奇怪。您可以尝试从 PyPI(64-bit Python 或 32-bit Python)下载适当的 Wheel 文件并尝试安装。 Cannot install pymssql on windows的可能重复 【参考方案1】:看看这个https://docs.microsoft.com/en-us/sql/connect/python/pymssql/step-1-configure-development-environment-for-pymssql-python-development
要选择正确的文件下载,您必须确定 cp 的数量 例如:cp27、cp36 等
import pip
print(pip.pep425tags.get_supported())
像这样: enter image description here
【讨论】:
【参考方案2】:通过 anaconda 使用 Python 的人,应以管理员身份在 anaconda 命令行中运行以下代码。
conda 安装 pymssql。
我已经测试并且工作正常,这大约需要 20-30 分钟,同时它还会安装所有其他依赖项。
【讨论】:
以上是关于在 Windows 10 上安装 pymssql 时出错的主要内容,如果未能解决你的问题,请参考以下文章
在 Mac OS 10.6 (python 2.6) 上安装/构建 pymssql