树莓派 - 用Python控制GPIO

5
我正在尝试让我的树莓派GPIO引脚工作,并且正在遵循如何将您的树莓派用作Arduino的教程
(我通过运行Raspbian的SSH进行工作。)我已经成功安装了distribute。
尝试安装PIP时,我遇到了下面显示的错误。
我该如何解决?
    pi@DuckPi ~ $ sudo curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100 85929  100 85929    0     0  89250      0 --:--:-- --:--:-- --:--:--  103k
    Downloading/unpacking pip
      Running setup.py egg_info for package pip

        warning: no files found matching '*.html' under directory 'docs'
        warning: no previously-included files matching '*.txt' found under directory 'docs/_build'
        no previously-included directories found matching 'docs/_build/_sources'
    Installing collected packages: pip
      Running setup.py install for pip
        error: could not create '/usr/local/lib/python2.7/dist-packages/pip': Permission denied
        Complete output from command /usr/bin/python -c "import setuptools;__file__='/home/pi/build/pip/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-6djiJW-record/install-record.txt:
        running install

    running build

    running build_py

    running install_lib

    creating /usr/local/lib/python2.7/dist-packages/pip

    error: could not create '/usr/local/lib/python2.7/dist-packages/pip': Permission denied

    ----------------------------------------
    Command /usr/bin/python -c "import setuptools;__file__='/home/pi/build/pip/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-6djiJW-record/install-record.txt failed with error code 1
    Storing complete log in /home/pi/.pip/pip.log
4个回答

6

这是因为使用了 sudo 命令而不是 python 命令来运行 curl。正确的命令是:

$ curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | sudo python

或者,如果您愿意的话,可以下载该文件,然后运行它:
$ curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
$ sudo python get-pip.py

您也可以使用sudo easy_install3 -U pip来获取最新版本的更新。 - Simara

2
现在Debian软件包的命名方式如下:
python-rpi.gpio - Python GPIO module for Raspberry Pi
python3-rpi.gpio - Python 3 GPIO module for Raspberry Pi

2

我按照相同的教程操作,但是没有安装pip,而是直接使用了:

sudo apt-get install rpi.gpio

在寻找一些额外信息后,教程的其余部分运作良好。我的整个简单GPIO介绍的体验是我博客文章的主题“使用树莓派GPIO接口”,我希望这也能有所帮助。


0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接