1. 步骤 :
- 打开 PyCharm 点击 “文件 / File”
- 选择 “工具 / Settings...”符号
- 选择" Project : ultralytics" --> " Python Interpreter " --> 右边的 "Add Interpreter" - -> 再点击 "Add Local Interpreter"
- 选择 “Conda Environment,” 之后在Conda Executable 中选择你的 Anaconda 路径中的Anaconda3\condabin\conda.bat ,最后在 Use existing environment 中选择你已经建立好的虚拟环境名称,点击OK,就完成啦!
2. 可能遇到问题:为什么pycharm添加不了conda创建的环境?
- 存在原因:1. 没有将anaconda添加到环境变量中;2. conda版本太低
- 方 法: 先查看是否已将anaconda添加到环境变量中,如已添加环境变量,可以尝试将conda升级到4.9或以上的版本。conda版本太低,pycharm无法找到conda虚拟环境的python解释器,就无法通过导入虚拟环境。
更新conda版本以及anaconda添加到环境变量的方法可参考:
https://blog.csdn.net/weixin_62495450/article/details/135923932?spm=1001.2014.3001.5502
3. 参考:
1.【Anaconda】pycharm导入虚拟环境
https://blog.csdn.net/aiscong/article/details/128737430?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522169503353316800185889273%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=169503353316800185889273&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~baidu_landing_v2~default-4-128737430-null-null.nonecase&utm_term=Pycharm%E5%AF%BC%E5%85%A5conda%E8%99%9A%E6%8B%9F%E7%8E%AF%E5%A2%83&spm=1018.2226.3001.4450
2.新版pycharm导入conda虚拟环境及常见问题、错误
https://blog.csdn.net/weixin_49183141/article/details/132991210
3.【最新版配置conda环境】新版pycharm导入新版anaconda环境
https://blog.csdn.net/aaatomaaa/article/details/133384239
4. pycharm无法加载conda解释器,以及终端无法检测到conda命令的解决方法
https://zhuanlan.zhihu.com/p/651403262#:~:text=%E7%84%B6%E8%80%8C%E5%8F%AF%E8%83%BD%E5%8F%88%E5%87%BA%E7%8E%B0%E9%97%AE%E9%A2%98%EF%BC%8C%E6%AF%94%E5%A6%82pycharm%E6%98%BE%E7%A4%BA%E6%89%BE%E4%B8%8D%E5%88%B0conda%E5%91%BD%E4%BB%A4%EF%BC%8C%20%E8%BF%99%E5%B0%B1%E6%98%AF%E5%9B%A0%E4%B8%BA%E7%B3%BB%E7%BB%9F%E7%9A%84%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E6%B7%BB%E5%8A%A0%E9%94%99%E8%AF%AF%E4%B8%8D%E6%88%90%E5%8A%9F%E5%AF%BC%E8%87%B4%E7%9A%84%EF%BC%8Cpycharm%E6%89%BE%E4%B8%8D%E5%88%B0%E8%BF%99%E4%B8%AAconda%20%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95%E6%98%AF%EF%BC%9A%20windows%E6%90%9C%E7%B4%A2%EF%BC%9A%E8%BE%93%E5%85%A5%E6%9F%A5%E7%9C%8B%E9%AB%98%E7%BA%A7%E7%B3%BB%E7%BB%9F%E8%AE%BE%E7%BD%AE%EF%BC%8C%E9%80%89%E6%8B%A9%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E3%80%82%20%E5%9C%A8%E4%B8%8B%E6%A0%8F%E7%9A%84%E7%B3%BB%E7%BB%9F%E5%8F%98%E9%87%8F%EF%BC%88S%EF%BC%89%E4%B8%AD%E6%89%BE%E5%88%B0Path%EF%BC%8C%E5%8F%8C%E5%87%BBPath,%E6%96%B0%E5%A2%9E%E4%B8%89%E8%A1%8Canaconda%E8%B7%AF%E5%BE%84%E5%8D%B3%E5%8F%AF%EF%BC%8C%E6%B3%A8%E6%84%8F%E8%87%AA%E5%B7%B1%E6%89%BE%E5%88%B0%E8%87%AA%E5%B7%B1%E7%9A%84%E5%AE%89%E8%A3%85%E7%9B%AE%E5%BD%95%E7%9A%84%E5%AF%B9%E5%BA%94%E8%B7%AF%E5%BE%84%20%E9%87%8D%E5%90%AF%E7%BB%88%E7%AB%AFpycharm%EF%BC%8C%E5%86%8D%E6%AC%A1%E6%89%A7%E8%A1%8Cconda%20init%20cmd.exe%E4%BB%A5%E5%8F%8Aconda%20init%20powershell%E5%8D%B3%E5%8F%AF%E9%87%8D%E7%BD%AE%E3%80%82