ConstStar
发布于 2023-11-16 / 56 阅读 / 0 评论 / 0 点赞

fprime创建项目出现的问题

运行到metadata(setup.py)会卡主报错

通过脚手架创建项目执行到下载python依赖时运行metadata(setup.py)会卡主报错,查阅fprime论坛发现运行matedata时会通过github下载一些依赖文件,所以解决方法就是设置linux中的http和https的全局代理。

也就是设置http_proxy和https_proxy环境变量。

以clash为例,开放端口7890,主机ip192.168.2.155

所以设置代理的命令就是:

export http_proxy="http://192.168.2.155:7890"
export https_proxy="http://192.168.2.155:7890"

可以通过wget https://ident.me/来查看当前ip

如果创建时出现

File "/tmp/tmp3r0pg4rk.py", line 17, in <module>
    response = requests.get("https://api.github.com/repos/nasa/fprime/releases/latest")
  File "/home/conststar/fprime-venv/lib/python3.10/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "/home/conststar/fprime-venv/lib/python3.10/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/conststar/fprime-venv/lib/python3.10/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/conststar/fprime-venv/lib/python3.10/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/home/conststar/fprime-venv/lib/python3.10/site-packages/requests/adapters.py", line 513, in send
    raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='api.github.com', port=443): Max retries exceeded with url: /repos/nasa/fprime/releases/latest (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f48cbca12d0>: Failed to establish a new connection: [Errno 111] Connection refused')))
Stopping generation because post_gen_project hook script didn't exit successfully
[ERROR] Hook script failed (exit status: 1)

类似这种的错误信息,就是机场不稳定,或者代理设置错误

可以通过下面的命令来查看代理是否设置正确,如果出现设置的url地址就是设置成功,但是也有可能主机ip和端口号不对

echo $http_proxy
echo $https_proxy

python提示json中有一个key不存在 KeyError: 'tag_name'

Traceback (most recent call last):
  File "/tmp/tmpxx14fy_l.py", line 18, in <module>
    latest_tag_name = response.json()["tag_name"]
KeyError: 'tag_name'

创建项目会访问github中一个的api,但是这个api有频率限制,所以解决方法就是在创建项目时前半段关闭代理,后半段下载依赖时开启代理。

[ERROR] Failed to create xxx. CMake erred with return code 2

创建最后面出现这句话[ERROR] Failed to create xxx. CMake erred with return code 2,是因为fprime对中文不兼容,需要将系统默认语言设置为英文。


评论