mac - pip 安装 pymssql 错误
mac - pip install pymssql error
我使用 Mac (OS X 10.11.5)。我想为 python 安装模块 pymssql
。
在 Terminal.app
中,我输入 sudo -H pip install pymssql
、pip install pymssql
、sudo pip install pymssql
。但是出现错误。
The directory /Users/janghyunsoo/Library/Caches/pip/http
or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip
with sudo
, you may want sudo
's -H
flag.
The directory /Users/janghyunsoo/Library/Caches/pip
or its parent directory is not owned by the current user and caching wheels has been disabled. Check the permissions and owner of that directory. If executing pip
with sudo
, you may want sudo
's -H
flag.
Collecting pymssql
Downloading pymssql-2.1.2.tar.gz (898kB)
100% |████████████████████████████████| 901kB 955kB/s
Installing collected packages: pymssql
Running setup.py install for pymssql ... error
Complete output from command /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-KA5ksi/pymssql/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-A3wRBy-record/install-record.txt --single-version-externally-managed --compile:
setup.py: platform.system() => 'Darwin'
setup.py: platform.architecture() => ('64bit', '')
setup.py: platform.libc_ver() => ('', '')
setup.py: Detected Darwin/Mac OS X.
You can install FreeTDS with Homebrew or MacPorts, or by downloading
and compiling it yourself.
Homebrew (http://brew.sh/)
--------------------------
brew install freetds
MacPorts (http://www.macports.org/)
-----------------------------------
sudo port install freetds
setup.py: Not using bundled FreeTDS
setup.py: include_dirs = ['/usr/local/include', '/opt/local/include', '/opt/local/include/freetds']
setup.py: library_dirs = ['/usr/local/lib', '/opt/local/lib']
running install
running build
running build_ext
building '_mssql' extension
creating build
creating build/temp.macosx-10.6-intel-2.7
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/opt/local/include -I/opt/local/include/freetds -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mssql.c -o build/temp.macosx-10.6-intel-2.7/_mssql.o -DMSDBLIB
_mssql.c:18924:15: error: use of undeclared identifier 'DBVERSION_80'
__pyx_r = DBVERSION_80;
^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-KA5ksi/pymssql/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-A3wRBy-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-KA5ksi/pymssql/
在 运行 安装 pip 之前,我可以通过 Homebrew 恢复到旧版本的 FreeTDS 来解决这个问题。
brew unlink freetds; brew install homebrew/versions/freetds091
andrewmwhite 在以下位置找到了解决方案:
https://github.com/pymssql/pymssql/issues/432
"brew install homebrew/python/pymssql" 也有效,但将从今天开始安装旧的 2.1.1。
投票最高的解决方案对我不起作用,因为 brew 本身没有 link 旧版本的 freetds。我这样做是为了解决问题:
brew unlink freetds;
brew install freetds@0.91;
brew link --force freetds@0.91
通过在 http://gree2.github.io/python/setup/2017/04/19/python-instal-pymssql-on-mac 上逐步安装 pymssql 找到了详细而简单的答案。
brew unlink freetds; brew install homebrew/core/freetds091
brew link --force freetds@0.91
pip install pymssql
找到 pip/python2 & pip3/python3
的解决方案
问题:
在@siva 和@himanshu 解决方法适用于 python2
但不适用于 python3
.
之后,我无法从 pip3 成功构建
pip3 install pymssql
..._mssql.c:21155:15: error: use of undeclared identifier 'DBVERSION_80'
__pyx_r = DBVERSION_80;
^
1 error generated.
error: command 'clang' failed with exit status 1
您的问题不是权限问题,而是 pymssql
.
的依赖代码的代码编译问题
Here's the discussion,
我在哪里找到 Solution on github.
It has been around for a while at this point, just placing here for visibility.
只需使用来自 gitub 的最新版本的 pymssql:
pip3 install git+https://github.com/pymssql/pymssql
也适用于 python2
pip install git+https://github.com/pymssql/pymssql
或
pip2 install git+https://github.com/pymssql/pymssql
我在 Mac OS X (10.13.6) & Homebrew (1.7.1-62-gddbefee)
上测试了多次。
该命令适用于两个版本的 freetds (0.91) 或 (1.00.94)
这对我有用 mac:
pip install cython
然后
pip install git+https://github.com/pymssql/pymssql.git
以上所有解决方案都运行良好。请注意,setup.py for pymssql pip install pymssql 预计 Homebrew 已在您机器上的 /sw 安装了 Freetds。
我的机器不是这种情况,所以我不得不使用这里的工作:
- 手动下载 pymssql 的 .tar 文件
- 打开setup.py
- 编辑变量 fink 以将路径添加到您机器上实际安装 Freetds 的位置。
if sys.platform == 'darwin':
fink = '<path to Freetds on your Machine>'
- 然后运行
python setup.py install
我使用 Mac (OS X 10.11.5)。我想为 python 安装模块 pymssql
。
在 Terminal.app
中,我输入 sudo -H pip install pymssql
、pip install pymssql
、sudo pip install pymssql
。但是出现错误。
The directory
/Users/janghyunsoo/Library/Caches/pip/http
or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executingpip
withsudo
, you may wantsudo
's-H
flag.The directory
/Users/janghyunsoo/Library/Caches/pip
or its parent directory is not owned by the current user and caching wheels has been disabled. Check the permissions and owner of that directory. If executingpip
withsudo
, you may wantsudo
's-H
flag.
Collecting pymssql
Downloading pymssql-2.1.2.tar.gz (898kB)
100% |████████████████████████████████| 901kB 955kB/s
Installing collected packages: pymssql
Running setup.py install for pymssql ... error
Complete output from command /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-KA5ksi/pymssql/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-A3wRBy-record/install-record.txt --single-version-externally-managed --compile:
setup.py: platform.system() => 'Darwin'
setup.py: platform.architecture() => ('64bit', '')
setup.py: platform.libc_ver() => ('', '')
setup.py: Detected Darwin/Mac OS X.
You can install FreeTDS with Homebrew or MacPorts, or by downloading
and compiling it yourself.
Homebrew (http://brew.sh/)
--------------------------
brew install freetds
MacPorts (http://www.macports.org/)
-----------------------------------
sudo port install freetds
setup.py: Not using bundled FreeTDS
setup.py: include_dirs = ['/usr/local/include', '/opt/local/include', '/opt/local/include/freetds']
setup.py: library_dirs = ['/usr/local/lib', '/opt/local/lib']
running install
running build
running build_ext
building '_mssql' extension
creating build
creating build/temp.macosx-10.6-intel-2.7
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/opt/local/include -I/opt/local/include/freetds -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mssql.c -o build/temp.macosx-10.6-intel-2.7/_mssql.o -DMSDBLIB
_mssql.c:18924:15: error: use of undeclared identifier 'DBVERSION_80'
__pyx_r = DBVERSION_80;
^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-KA5ksi/pymssql/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-A3wRBy-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-KA5ksi/pymssql/
在 运行 安装 pip 之前,我可以通过 Homebrew 恢复到旧版本的 FreeTDS 来解决这个问题。
brew unlink freetds; brew install homebrew/versions/freetds091
andrewmwhite 在以下位置找到了解决方案: https://github.com/pymssql/pymssql/issues/432
"brew install homebrew/python/pymssql" 也有效,但将从今天开始安装旧的 2.1.1。
投票最高的解决方案对我不起作用,因为 brew 本身没有 link 旧版本的 freetds。我这样做是为了解决问题:
brew unlink freetds;
brew install freetds@0.91;
brew link --force freetds@0.91
通过在 http://gree2.github.io/python/setup/2017/04/19/python-instal-pymssql-on-mac 上逐步安装 pymssql 找到了详细而简单的答案。
brew unlink freetds; brew install homebrew/core/freetds091
brew link --force freetds@0.91
pip install pymssql
找到 pip/python2 & pip3/python3
的解决方案问题:
在@siva 和@himanshu 解决方法适用于 python2
但不适用于 python3
.
pip3 install pymssql
..._mssql.c:21155:15: error: use of undeclared identifier 'DBVERSION_80'
__pyx_r = DBVERSION_80;
^
1 error generated.
error: command 'clang' failed with exit status 1
您的问题不是权限问题,而是 pymssql
.
Here's the discussion, 我在哪里找到 Solution on github.
It has been around for a while at this point, just placing here for visibility.
只需使用来自 gitub 的最新版本的 pymssql:
pip3 install git+https://github.com/pymssql/pymssql
也适用于 python2
pip install git+https://github.com/pymssql/pymssql
或
pip2 install git+https://github.com/pymssql/pymssql
我在 Mac OS X (10.13.6) & Homebrew (1.7.1-62-gddbefee)
上测试了多次。
该命令适用于两个版本的 freetds (0.91) 或 (1.00.94)
这对我有用 mac:
pip install cython
然后
pip install git+https://github.com/pymssql/pymssql.git
以上所有解决方案都运行良好。请注意,setup.py for pymssql pip install pymssql 预计 Homebrew 已在您机器上的 /sw 安装了 Freetds。
我的机器不是这种情况,所以我不得不使用这里的工作:
- 手动下载 pymssql 的 .tar 文件
- 打开setup.py
- 编辑变量 fink 以将路径添加到您机器上实际安装 Freetds 的位置。
if sys.platform == 'darwin':
fink = '<path to Freetds on your Machine>'
- 然后运行
python setup.py install