记一次安装ESP32开发环境:ESP-IDF安装配置的排坑之旅
esp官方文档:快速入门
https://docs.espressif.com/projects/esp-idf/zh_CN/stable/get-started/
按常理来说应该不会出现什么问题啊,但是确实出现了大问题。
截图如下:
更换了linux下按照官方文档运行也是出现出现了类似的问题
所以,问题到底出在哪里?
根据报错,我们可以定位subprocess.py这个自带库中的CalledProcessError()这个方法
def check_call(*popenargs, **kwargs): """Run command with arguments. Wait for command to complete. If the exit code was zero then return, otherwise raise CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute. The arguments are the same as for the Popen constructor. Example: check_call(["ls", "-l"]) """ retcode = call(*popenargs, **kwargs) if retcode: cmd = kwargs.get("args") if cmd is None: cmd = popenargs[0] raise CalledProcessError(retcode, cmd) return 0
这句话中我们清楚的看到,函数引发了一个CalledProcessEroor异常,而异常引发的原因正是无法正常结束命令的调用
我们现在回到引发异常的关键文件idf_tools.py看看他是怎么调用这个函数的
def action_install_python_env(args): idf_python_env_path, _, virtualenv_python = get_python_env_path() is_virtualenv = hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix) if is_virtualenv and (not os.path.exists(idf_python_env_path) or args.reinstall): fatal('This script was called from a virtual environment, can not create a virtual environment again') raise SystemExit(1) if args.reinstall and os.path.exists(idf_python_env_path): warn('Removing the existing Python environment in {}'.format(idf_python_env_path)) shutil.rmtree(idf_python_env_path) if not os.path.exists(virtualenv_python): info('Creating a new Python environment in {}'.format(idf_python_env_path)) try: import virtualenv # noqa: F401 except ImportError: info('Installing virtualenv') subprocess.check_call([sys.executable, '-m', 'pip', 'install', '--user', 'virtualenv'], stdout=sys.stdout, stderr=sys.stderr) subprocess.check_call([sys.executable, '-m', 'virtualenv', idf_python_env_path], stdout=sys.stdout, stderr=sys.stderr) run_args = [virtualenv_python, '-m', 'pip', 'install', '--no-warn-script-location'] requirements_txt = os.path.join(global_idf_path, 'requirements.txt') run_args += ['-r', requirements_txt] if args.extra_wheels_dir: run_args += ['--find-links', args.extra_wheels_dir] info('Installing Python packages from {}'.format(requirements_txt)) subprocess.check_call(run_args, stdout=sys.stdout, stderr=sys.stderr)
定位到最后一句代码:
subprocess.check_call(run_args, stdout=sys.stdout, stderr=sys.stderr)
引发了异常
这里run_args是输入一串执行参数命令,对应的,就是我们平时在命令行里面输入的东西,现在python帮你完成,具体调用了什么命令行参数?
我们来看看报错信息
Traceback (most recent call last): File "/home/ssss/桌面/esp-idf/tools/idf_tools.py", line 1492, in <module> main(sys.argv[1:]) File "/home/ssss/桌面/esp-idf/tools/idf_tools.py", line 1488, in main action_func(args) File "/home/ssss/桌面/esp-idf/tools/idf_tools.py", line 1215, in action_install_python_env subprocess.check_call(run_args, stdout=sys.stdout, stderr=sys.stderr) File "/usr/lib/python2.7/subprocess.py", line 190, in check_call raise CalledProcessError(retcode, cmd) subprocess.CalledProcessError: Command '['/root/.espressif/python_env/idf4.3_py2.7_env/bin/python', '-m', 'pip', 'install', '--no-warn-script-location', '-r', '/home/mastwet/\xe6\xa1\x8c\xe9\x9d\xa2/esp-idf/requirements.txt']' returned non-zero exit status 2
我们可以看到,
/home/ssss/桌面/esp-idf/tools/requirements.txt
被解析成了
'/home/mastwet/\xe6\xa1\x8c\xe9\x9d\xa2/esp-idf/requirements.txt'
所以说结论,原因是不能够将文件安放在带有中文路径的目录下!
还没结束!我发现其实windows下的报错和linux下的报错还是有区别
最后发现导致安装不上的竟然是网络问题!
最后解决方法还是老生常谈的pip换元大法
全局更新pip环境,具体可参照这篇文章
posted on 2020-08-10 10:42 大湿Mastwet 阅读(11915) 评论(0) 编辑 收藏 举报
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· 2 本地部署DeepSeek模型构建本地知识库+联网搜索详细步骤