簡體   English   中英

pip install pygraphviz:找不到包“libcgraph”

[英]pip install pygraphviz: No package 'libcgraph' found

我成功安裝了graphvizcgraph

$ sudo pip install graphviz
....
Successfully installed graphviz-0.5.1

$ sudo pip install cgraph
...
Successfully installed cgraph-0.1

我遇到問題No package 'libcgraph' found while running sudo pip install pygraphviz 以下是完整的堆棧跟蹤。

$ sudo pip install pygraphviz
The directory '/Users/sparkandshine/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/sparkandshine/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 pygraphviz
  Downloading pygraphviz-1.3.1.zip (123kB)
    100% |████████████████████████████████| 133kB 1.5MB/s 
Installing collected packages: pygraphviz
  Running setup.py install for pygraphviz ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-qfFpFG/pygraphviz/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-JmwjA6-record/install-record.txt --single-version-externally-managed --compile:
    running install
    Trying pkg-config
    Package libcgraph was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libcgraph.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libcgraph' found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/tmp/pip-build-qfFpFG/pygraphviz/setup.py", line 87, in <module>
        tests_require=['nose>=0.10.1', 'doctest-ignore-unicode>=0.1.0',],
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 151, in setup
        dist.run_commands()
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "setup_commands.py", line 44, in modified_run
        self.include_path, self.library_path = get_graphviz_dirs()
      File "setup_extra.py", line 121, in get_graphviz_dirs
        include_dirs, library_dirs = _pkg_config()
      File "setup_extra.py", line 44, in _pkg_config
        output = S.check_output(['pkg-config', '--libs-only-L', 'libcgraph'])
      File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 573, in check_output
        raise CalledProcessError(retcode, cmd, output=output)
    subprocess.CalledProcessError: Command '['pkg-config', '--libs-only-L', 'libcgraph']' returned non-zero exit status 1

    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-qfFpFG/pygraphviz/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-JmwjA6-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-qfFpFG/pygraphviz/

我嘗試了Python提供的解決方案沒有看到 pygraphviz ,但它不起作用。

sudo apt-get install python-dev graphviz libgraphviz-dev pkg-config

或者,如果您使用的是 Python 3,則可能需要以下內容:

sudo apt-get install python3-dev graphviz libgraphviz-dev pkg-config

那么

pip install pygraphviz

對於 MacOS,我需要執行以下操作:

$ brew install graphviz
$ sudo pip install pygraphviz 

對於 Fedora 用戶:

  1. yum 列表可用graphviz*
  2. 為您的 Fedora 發行版選擇合適的軟件包
  3. sudo yum install 'graphviz-devel.x86_64'
  4. pip install pygraphviz

在 macOS 上,我做到了,

$ brew install graphviz
$ sudo pip install pygraphviz

對於 CentOS。 由於需要使用 graphviz-devel 來解決此問題,因此您需要使用 yum 安裝它。 為此,您需要在包可用的地方添加 repo。 就我而言, Atomic repos 工作正常。

wget -q -O - http://www.atomicorp.com/installers/atomic | sh

這將添加原子回購,然后

sudo yum install graphviz-devel

你應該能夠執行

pip install pygraphviz

我在使用 python-alpine 圖像為 Django 創建 Dockerfile 時遇到了這個問題。

由於這篇文章添加了包“graphviz-dev”以及我的應用程序的其余依賴項,我能夠解決它。

示例:

#Install dependencies
RUN apk add --update --no-cache --virtual .build-deps \
    build-base \
    alpine-sdk \
    postgresql-dev \
    libffi-dev \
    python3-dev \
    libffi-dev \
    jpeg-dev \
    zlib-dev \
    musl-dev \
    libpq \
    graphviz-dev \  
    && pip install --no-cache-dir -r /code/requirements_dev.txt \
    && find /usr/local \
        \( -type d -a -name test -o -name tests \) \
        -o \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
        -exec rm -rf '{}' +

問候

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM