LoginSignup
0
0

More than 5 years have passed since last update.

ラズパイでsudo pythonして色々怒られた時の対策

Posted at

wiringpiを利用する時など、pythonを管理者権限で実行しないといけない時ってありますよね。

そんなとき以下のような感じで怒られた時の対策です。

私はラズパイ3にpyenvを入れ、その上でpython3へ設定した環境で起きました。

$ sudo python foo.py
Traceback (most recent call last):
  File "bar.py", line x, in <module>
    bar = bar()
.
.
.
ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters

要は管理者権限にすることでパスがわからなくなっているんだと思います。

ですので

$ sudo /home/pi/.pyenv/shims/python /home/pi/foo.py

とすればうまくいきます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0