【问题标题】:Python setup does not find correctly installed module using pkg-configPython 安装程序找不到使用 pkg-config 正确安装的模块
【发布时间】:2013-06-05 17:06:45
【问题描述】:

首先,我不知道python。我认为这就是我遇到问题的原因。 我正在尝试从源代码构建 compiz,但我坚持构建 simple-ccsm。 simple-ccsm 的设置是使用 python 和 setup.py。 安装时,它抱怨:

Package compiz was not found in the pkg-config search path.
Perhaps you should add the directory containing 'compiz.pc'
to the PKG_CONFIG_PATH environment variable
No package 'compiz' was found

现在,PKG_CONFIG_PATH 确实指向了正确的文件夹。而且pkg-config还可以正确找到compiz:

pkg-config --libs compiz

它确实安装了 simple-ccsm,但是当我运行它时,simple-ccsm 抱怨失败

ImportError: No module named compizconfig

我已经安装了 simple-ccsm 所需的所有依赖项(包括 compizconfig-python 绑定,它似乎通常会给出上述错误) 所以,想请教python高手,如何引导python找对地方。我猜它在某种程度上没有在正确的目录中查找。

【问题讨论】:

    标签: python linux compiz


    【解决方案1】:

    要将 Python 引导到正确的位置,您可能需要修改 PYTHONPATH:(正在编辑,因为链接已损坏)。

    PYTHONPATH sets the search path for importing python modules:
    
    PYTHONPATH Augment the default search path for module files. The format is 
    the same as the shell’s PATH: one or more directory pathnames separated by 
    os.pathsep (e.g. colons on Unix or semicolons on Windows). Non-existent 
    directories are silently ignored.
    
    In addition to normal directories, individual PYTHONPATH entries may refer 
    to zipfiles containing pure Python modules (in either source or compiled 
    form). Extension modules cannot be imported from zipfiles.
    
    The default search path is installation dependent, but generally begins with 
    prefix/lib/pythonversion (see PYTHONHOME above). It is always appended to 
    PYTHONPATH.
    
    An additional directory will be inserted in the search path in front of 
    PYTHONPATH as described above under Interface options. The search path can 
    be manipulated from within a Python program as the variable sys.path.
    

    要设置变量,请在运行 python 脚本时指定它:

    PYTHONPATH=/blah/whatever/ python somescript.py somecommand

    或将其导出到您的 Bash 环境:

    export PYTHONPATH=/blah/whatever/

    【讨论】:

    • 感谢您的信息。尽管 ccsm 仍然给我错误,但我能够了解一些有关 python 以及 ccsm 失败的原因。
    • 这就是为什么仅链接的答案是不可接受的。该链接打不开,因为它不存在
    猜你喜欢
    • 1970-01-01
    • 2014-07-04
    • 1970-01-01
    • 1970-01-01
    • 2013-08-26
    • 2013-07-10
    • 2015-05-13
    • 2021-11-23
    • 2019-11-14
    相关资源
    最近更新 更多