什么`找不到符号:_clock_gettime`在调用python 2.7脚本时是什么意思?

时间:2018-04-17 21:45:56

标签: python macos pip

自制安装的python 2.7.13安装出了问题,所以我清理了用自制软件安装的所有内容并从头开始。我仍然得到以下错误,引用PIL中的文件(Pillow已经安装了pip)。我该如何修复这个似乎已损坏的库,但刚刚重新安装?

$ python2 src/ks.py
  ---  module "start"
Traceback (most recent call last):
  File "src/ks.py", line 29, in <module>
    from PIL import ImageTk, Image
  File "/usr/local/lib/python2.7/site-packages/PIL/ImageTk.py", line 42, in <module>
    from . import Image
  File "/usr/local/lib/python2.7/site-packages/PIL/Image.py", line 60, in <module>
    from . import _imaging as core
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/PIL/_imaging.so, 2): Symbol not found: _clock_gettime
  Referenced from: /usr/local/lib/python2.7/site-packages/PIL/.dylibs/liblzma.5.dylib (which was built for Mac OS X 10.12)
  Expected in: /usr/lib/libSystem.B.dylib
 in /usr/local/lib/python2.7/site-packages/PIL/.dylibs/liblzma.5.dylib

以下我所做的一切都达到了这一点:
- 检查brew list是否为空 - 安装python@2
- 列出pip安装的项目
- 更新点子 - 卸载枕头(只是为了确保)
- 列出pip安装的项目(确保卸载成功)
- 重新安装枕头
- 列出pip安装的项目(确保重新安装成功)
- 运行我的脚本
- 我还检查了python2 --versionpip --version,并且都确认自制安装与系统安装的python是分开的。

+++++++++++++++++++++++++++++++++++++++++

$ brew list
gdbm        python      readline    xz
openssl     python@2    sqlite
[user@host]
$ brew install python@2
==> Downloading https://homebrew.bintray.com/bottles/python@2-2.7.14_3.el_capitan.bo
Already downloaded: /Users/benfound/Library/Caches/Homebrew/python@2-2.7.14_3.el_capitan.bottle.1.tar.gz
==> Pouring python@2-2.7.14_3.el_capitan.bottle.1.tar.gz
==> /usr/local/Cellar/python@2/2.7.14_3/bin/python -s setup.py --no-user-cfg install
==> /usr/local/Cellar/python@2/2.7.14_3/bin/python -s setup.py --no-user-cfg install
==> /usr/local/Cellar/python@2/2.7.14_3/bin/python -s setup.py --no-user-cfg install
==> Caveats
Pip and setuptools have been installed. To update them
  pip install --upgrade pip setuptools

You can install Python packages with
  pip install <package>

They will install into the site-package directory
  /usr/local/lib/python2.7/site-packages

See: https://docs.brew.sh/Homebrew-and-Python
==> Summary
  /usr/local/Cellar/python@2/2.7.14_3: 4,602 files, 81.9MB
[user@host]
$ pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
Pillow (5.1.0)
pip (9.0.3)
setuptools (38.5.2)
wheel (0.30.0)
You are using pip version 9.0.3, however version 10.0.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[user@host]
$ pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/62/a1/0d452b6901b0157a0134fd27ba89bf95a857fbda64ba52e1ca2cf61d8412/pip-10.0.0-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 641kB/s 
Installing collected packages: pip
  Found existing installation: pip 9.0.3
    Uninstalling pip-9.0.3:
      Successfully uninstalled pip-9.0.3
Successfully installed pip-10.0.0
[user@host]
$ pip uninstall Pillow
Uninstalling Pillow-5.1.0:
  Would remove:
    /usr/local/lib/python2.7/site-packages/PIL/*
    /usr/local/lib/python2.7/site-packages/Pillow-5.1.0.dist-info/*
Proceed (y/n)? y
  Successfully uninstalled Pillow-5.1.0
[user@host]
$ pip list
Package    Version
---------- -------
pip        10.0.0 
setuptools 38.5.2 
wheel      0.30.0 
[user@host]
$ pip install Pillow
Collecting Pillow
  Downloading https://files.pythonhosted.org/packages/df/aa/a25f211a4686f363d8ca5a1752c43a8f42459e70af13e20713d3e636f0af/Pillow-5.1.0-cp27-cp27m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (3.6MB)
    100% |████████████████████████████████| 3.6MB 2.8MB/s 
Installing collected packages: Pillow
Successfully installed Pillow-5.1.0
[user@host]
$ pip list
Package    Version
---------- -------
Pillow     5.1.0  
pip        10.0.0 
setuptools 38.5.2 
wheel      0.30.0 
[user@host]
$ python2 src/ks.py
  ---  module "start"
Traceback (most recent call last):
  File "src/ks.py", line 29, in <module>
    from PIL import ImageTk, Image
  File "/usr/local/lib/python2.7/site-packages/PIL/ImageTk.py", line 42, in <module>
    from . import Image
  File "/usr/local/lib/python2.7/site-packages/PIL/Image.py", line 60, in <module>
    from . import _imaging as core
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/PIL/_imaging.so, 2): Symbol not found: _clock_gettime
  Referenced from: /usr/local/lib/python2.7/site-packages/PIL/.dylibs/liblzma.5.dylib (which was built for Mac OS X 10.12)
  Expected in: /usr/lib/libSystem.B.dylib
 in /usr/local/lib/python2.7/site-packages/PIL/.dylibs/liblzma.5.dylib
[user@host]

我检查确保安装了xcode-select CLI工具,并删除并重新安装它们以确保...

$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
[user@host]
$ rm -rf /Library/Developer/CommandLineTools/
[user@host]
$ sudo !!
sudo rm -rf /Library/Developer/CommandLineTools/
Password:
[user@host]
$ xcode-select --install
xcode-select: note: install requested for command line developer tools
[user@host]

我还试过了brew doctor,这给了PATH一个问题,我修改了.bash_profile的更新:

[user@host]
$ echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin
$ brew doctor
...(snip)
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  python

Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:
...(snip)

Consider setting your PATH so that /usr/local/bin
occurs before /usr/bin. Here is a one-liner:
  echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile
[user@host]
$ echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin

...但同样的错误仍然存​​在。什么是损坏的模块或库,我该如何解决?是否需要在系统级python安装中修复某些内容,或者是否需要重新安装操作系统?

这是使用OS X 10.11.6(El Capitan)。升级目前不是一个选项(10.12.x或更高)。我最近尝试在这台主机上运行最新版本的xcode,但操作系统并不支持它,我在找到它后删除了应用程序。我认为这可能会损坏某些内容,但我已经重新安装了xcode工具。

2 个答案:

答案 0 :(得分:3)

此问题已通过其他问题排查here得到解答。根本原因是Pillow 5.1.0中的一个错误。

答案 1 :(得分:2)

将您的枕头版本降级至5.0.0

private void txtdiscount_TextChanged_1(object sender, EventArgs e)
{
    if (txtsubtotal.Text == "" || txtdiscount.Text == "")
        return;
    txtgrandtotal.Text = (Convert.ToDouble(txtsubtotal.Text) - (Convert.ToDouble(txtdiscount.Text) * Convert.ToDouble(txtsubtotal.Text))).ToString("#,0.00");
}