在 Ubuntu 上安装 python3-picamera

Install python3-picamera on Ubuntu

我想在 Ubuntu 20.04 上安装 picamera

sudo pip install picamera 之后发生以下错误。

如何安装 picamera

ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_s89vs5d/picamera/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_s89vs5d/picamera/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-1cbs8kpu
       cwd: /tmp/pip-install-_s89vs5d/picamera/
  Complete output (54 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib
  creating build/lib/picamera
  copying picamera/mmal.py -> build/lib/picamera
  copying picamera/camera.py -> build/lib/picamera
  copying picamera/encoders.py -> build/lib/picamera
  copying picamera/exc.py -> build/lib/picamera
  copying picamera/streams.py -> build/lib/picamera
  copying picamera/color.py -> build/lib/picamera
  copying picamera/__init__.py -> build/lib/picamera
  copying picamera/array.py -> build/lib/picamera
  copying picamera/display.py -> build/lib/picamera
  copying picamera/bcm_host.py -> build/lib/picamera
  copying picamera/mmalobj.py -> build/lib/picamera
  copying picamera/renderers.py -> build/lib/picamera
  copying picamera/frames.py -> build/lib/picamera
  running egg_info
  writing picamera.egg-info/PKG-INFO
  writing dependency_links to picamera.egg-info/dependency_links.txt
  writing requirements to picamera.egg-info/requires.txt
  writing top-level names to picamera.egg-info/top_level.txt
  reading manifest file 'picamera.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  no previously-included directories found matching 'debian'
  no previously-included directories found matching 'docs'
  writing manifest file 'picamera.egg-info/SOURCES.txt'
  installing to build/bdist.linux-x86_64/wheel
  running install
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-install-_s89vs5d/picamera/setup.py", line 145, in <module>
      main()
    File "/tmp/pip-install-_s89vs5d/picamera/setup.py", line 119, in main
      setup(
    File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 144, in setup
      return distutils.core.setup(**attrs)
    File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
      self.run_command(cmd)
    File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/usr/lib/python3/dist-packages/wheel/bdist_wheel.py", line 259, in run
      self.run_command('install')
    File "/usr/lib/python3.8/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
      cmd_obj.run()
    File "/tmp/pip-install-_s89vs5d/picamera/setup.py", line 111, in run
      raise ValueError('Unable to determine if this system is a Raspberry Pi')
  ValueError: Unable to determine if this system is a Raspberry Pi
  ----------------------------------------
  ERROR: Failed building wheel for picamera
  Running setup.py clean for picamera
Failed to build picamera
Installing collected packages: picamera
    Running setup.py install for picamera ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_s89vs5d/picamera/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_s89vs5d/picamera/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-record-sja1u8l0/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/picamera
         cwd: /tmp/pip-install-_s89vs5d/picamera/
    Complete output (18 lines):
    running install
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-_s89vs5d/picamera/setup.py", line 145, in <module>
        main()
      File "/tmp/pip-install-_s89vs5d/picamera/setup.py", line 119, in main
        setup(
      File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 144, in setup
        return distutils.core.setup(**attrs)
      File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/tmp/pip-install-_s89vs5d/picamera/setup.py", line 111, in run
        raise ValueError('Unable to determine if this system is a Raspberry Pi')
    ValueError: Unable to determine if this system is a Raspberry Pi
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_s89vs5d/picamera/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_s89vs5d/picamera/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-record-sja1u8l0/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/picamera Check the logs for full command output.

您可以直接从 GitHub repository

安装
$ lsb_release -a
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:    20.04
Codename:   focal

$ sudo pip3 install git+https://github.com/waveform80/picamera
Collecting git+https://github.com/waveform80/picamera
  Cloning https://github.com/waveform80/picamera to /tmp/pip-req-build-g87qbbfe
Building wheels for collected packages: picamera
  Building wheel for picamera (setup.py) ... done
  Created wheel for picamera: filename=picamera-1.13-py3-none-any.whl size=149553 sha256=869dfec10553ed3d55921a8e6ad118f74c63e3fb7efa6dec86366552d9802ef0
  Stored in directory: /tmp/pip-ephem-wheel-cache-wkr6b3lc/wheels/f5/63/a9/e2e3f131874542cea00b390274e75fb6845420358a8752d61a
Successfully built picamera
Installing collected packages: picamera
Successfully installed picamera-1.13