首页 > 解决方案 > PyCharm 无法导入模块

问题描述

我在 Linux 机器上使用 PyCharm。通常,当我导入一个模块时,例如。OpenCV 或 numpy,它工作得很好。但是当我尝试导入 gphoto2 时,出现以下错误。

Collecting gphoto2
  Using cached gphoto2-2.2.2.tar.gz (1.9 MB)

DEPRECATION: The -b/--build/--build-dir/--build-directory option is deprecated. pip 20.3 will remove support for this functionality. A possible replacement is use the TMPDIR/TEMP/TMP environment variable, possibly combined with --no-clean. You can find discussion regarding this at https://github.com/pypa/pip/issues/8333.
    ERROR: Command errored out with exit status 1:
     command: /home/anders/PycharmProjects/pythonProject/venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pycharm-packaging/gphoto2/setup.py'"'"'; __file__='"'"'/tmp/pycharm-packaging/gphoto2/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-srufwxku
         cwd: /tmp/pycharm-packaging/gphoto2/
    Complete output (10 lines):
    ERROR: command "pkg-config --modversion libgphoto2" failed
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pycharm-packaging/gphoto2/setup.py", line 36, in <module>
        cmd, stderr=FNULL, universal_newlines=True).split('.')[:3]
      File "/usr/lib/python3.7/subprocess.py", line 395, in check_output
        **kwargs).stdout
      File "/usr/lib/python3.7/subprocess.py", line 487, in run
        output=stdout, stderr=stderr)
    subprocess.CalledProcessError: Command '['pkg-config', '--modversion', 'libgphoto2']' returned non-zero exit status 1.
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

有人可以帮帮我吗?

标签: pythonlinuxpycharm

解决方案


推荐阅读