运行脚本时出现OSError

时间:2020-02-04 09:07:11

标签: python macos chirp

我试图设置ChirpSDK,但是每次我配置和运行代码时,都会出现此错误:

  Traceback (most recent call last):
  File "test.py", line 3, in <module>
    chirp = ChirpSDK()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chirpsdk/chirpsdk.py", line 395, in __init__
    self.read_chirprc(block)
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chirpsdk/chirpsdk.py", line 501, in read_chirprc
    raise IOError('Could not find a ~/.chirprc file')
OSError: Could not find a ~/.chirprc file
Exception ignored in: <function ChirpSDK.__del__ at 0x10fa31af0>
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chirpsdk/chirpsdk.py", line 422, in __del__
    self.close()
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/chirpsdk/chirpsdk.py", line 470, in close
    if self._sdk:
AttributeError: 'ChirpSDK' object has no attribute '_sdk'

我意识到错误表明我的.chirprc文件未被识别,但是我不知道如何解决此问题。我在/ Users / username /路径中创建了一个.chirprc文件,并将其命名为c.chirprc(正如Chirp入门文章所建议的那样),但是仍然出现此错误。我还有其他地方想念吗?我看错说明了吗?

谢谢

1 个答案:

答案 0 :(得分:0)

Chirp配置文件应放置在macOS上的/Users/<username>/.chirprc上。

如果您在终端中运行ls -l ~/.chirprc,会得到任何结果吗?如果没有显示此类文件或目录,则说明您未正确创建文件。