python - homebrew和pyenv冲突
怪我咯
怪我咯 2017-04-17 15:43:16
0
1
950

求解homebrew安装的python编译过程中添加了什么特殊的参数? 原问题改为:homebrew 和 pyenv 存在什么冲突,该如何解决?

问题来源: 1. 在osX上使用homebrew安装vtk模块时,会安装依赖的python,然后将vtk模块安装到brew安装的python中,使用系统python版本导入没有问题; 2. 但是我使用的是pyenv管理python版本,所以当我使用brew安装好vtk模块,并且将其链接到pyenv管理下的python包路径中时,使用vtk模块报错:

[liangzb@ ~/.pyenv/versions/2.7.10/lib/python2.7/site-packages]
$ pyenv global system
[liangzb@ ~/.pyenv/versions/2.7.10/lib/python2.7/site-packages]
$ python -c 'import vtk'
[liangzb@ ~/.pyenv/versions/2.7.10/lib/python2.7/site-packages]
$ pyenv global 2.7.10
[liangzb@ ~/.pyenv/versions/2.7.10/lib/python2.7/site-packages]
$ python -c 'import vtk'
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6

类似的问题我在ubuntu上也碰到过,当时ubuntu上的报错是因为系统的python使用ucs4编译,而pyenv默认使用ucs2编译,将pyenv管理的python重新编译之后就可以正常使用。在osX上碰到这个问题,是否也是因为brew在安装python的过程中会添加特殊的编译参数。 我尝试使用brew安装时的参数,但是似乎是非法的configure参数(以下参数除了prefix之外都复制了brew安装时的参数),调整部分参数编译成功后,问题任然存在:

$ ./configure --prefix=~/.pyenv/versions/2.7.10 --enable-ipv6 --enable-framework=~/.pyenv/versions/2.7.10/Framworks --without-ensurepip --without-gcc CPPFLAGS=-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include CFLAGS=-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers LDFLAGS=-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk MACOSX_DEPLOYMENT_TARGET=10.10
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk
configure: error: unrecognized option: `-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers'
Try `./configure --help' for more information

我在stackoverflow上也看到类似的问题,但是是/System下的python和homebrew的python冲突,应该不一样

按@JeffreyLEE提供的地址:https://github.com/Homebrew/homebrew/issues/13654 尝试将python和vtk重装,但是仍然存在问题:

[liangzb@ /Library/Frameworks]
$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:

  /Users/liangzb/.pyenv/shims/python-config
  /Users/liangzb/.pyenv/shims/python2-config
  /Users/liangzb/.pyenv/shims/python2.7-config
  /Users/liangzb/.pyenv/shims/python3-config
  /Users/liangzb/.pyenv/shims/python3.4-config
  /Users/liangzb/.pyenv/shims/python3.4m-config
^C
[liangzb@ /Library/Frameworks]
$ brew config
HOMEBREW_VERSION: 0.9.5
ORIGIN: https://github.com/Homebrew/homebrew
HEAD: 5d4f21fe8d0de114496e766e63124e7daf66d1ee
Last commit: 24 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://homebrew.bintray.com
CPU: quad-core 64-bit haswell
OS X: 10.10.4-x86_64
Xcode: 6.4
CLT: N/A
Clang: 6.1 build 602
X11: 2.7.7 => /opt/X11
System Ruby: 2.0.0-p481
Perl: /Users/liangzb/.plenv/shims/perl
Python: /Users/liangzb/.pyenv/shims/python => /Users/liangzb/.pyenv/versions/2.7.10/bin/python2.7
Ruby: /usr/bin/ruby
Java: 1.8.0_45

brew doctor显示pyenv的config文件可能会引起冲突,难道真的没办法共存了吗?

怪我咯
怪我咯

走同样的路,发现不同的人生

membalas semua(1)
小葫芦

将版本号写入当前目录下的 .python-version 文件的方式 试试
http://chrisna.org/2014/12/18/you-complete-me-on-my-terms/
使用下面的命令

pyenv local 2.7.3
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan