python - 如何在Win10上正确安装Python、VSCode、flake8
问题描述
对于新手的问题,我深表歉意。我正在尝试正确下载 Python 3.7 安装并将其与 VSCode 集成,并使用 flake8 作为 linter。我想为 Blender 开发自定义脚本做好准备。我在Win10 x64上。
- 我下载了“python-3.7.8-amd64.exe”安装包,安装好了。
- 我确保选中了将 python 添加到安装程序中的 PATH 环境变量的复选框。
- 我将 VSCode 指向新安装的解释器,然后被提示安装 linter。
- 有人推荐了 flake8,所以我在 VSCode 中选择了它并安装了。
- 在安装过程中,我收到以下警告:
WARNING: The script pyflakes.exe is installed in 'C:\Users\futur\AppData\Roaming\Python\Python37\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script pycodestyle.exe is installed in 'C:\Users\futur\AppData\Roaming\Python\Python37\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script flake8.exe is installed in 'C:\Users\futur\AppData\Roaming\Python\Python37\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed flake8-3.8.3 importlib-metadata-1.7.0 mccabe-0.6.1 pycodestyle-2.6.0 pyflakes-2.2.0 zipp-3.1.0
我检查了我的环境变量,结果如下:
我不明白为什么我在 %APPDATA% 中有两个 Python 目录。有:
C:\Users\futur\AppData\Local\Programs\Python\Python37\Scripts
也:
C:\Users\futur\AppData\Roaming\Python\Python37\Scripts
flake8 安装在 Roaming 文件夹中,而我的主要 Python 安装在
C:\Users\futur\AppData\Local\Programs\Python\Python37
总而言之,这些是我的问题:
- flake8 是否安装在错误的目录中?
- 我应该添加
C:\Users\futur\AppData\Roaming\Python\Python37\Scripts
到我的 USER PATH 环境变量还是我的 SYSTEM PATH 环境变量? - 为什么 %appdata% 中有两个 Python 目录?(漫游和本地)
任何关于如何正确设置一切的指导都将是一个巨大的帮助,非常感谢。
编辑 1
非常感谢所有的答案。我想强调一下,我更愿意在不安装 Anaconda 的情况下解决这个问题。
编辑 2
我在这里取得了一些进展。我没有通过 VSCode 安装 flake8,而是跑了python -m pip install flake8
,现在一切似乎都很好。
解决方案
根据你的描述,我成功安装了 flake8。
我觉得你flake8的安装路径有问题。
其默认路径不会处于漫游状态。默认路径将只有:C:\Users\futur\AppData\Local\Programs\Python\Python37\Scripts 和 C:\Users\futur\AppData\Local\Programs\Python\Python37;</p>
默认为本地,通常存放可执行程序等大容量文件;
建议您可以重新安装python并检查pip的版本和位置(使用“pip --version”)。
推荐阅读
- xcode - StoreKit + SwiftUI 预览 - 没有这样的模块 '_StoreKit_SwiftUI'
- php - 如何解决 Symfony/Goutte 中的 SSL 问题
- javascript - 如何在提交后或使用 formik 单击取消按钮后重置表单
- ruby - 递归查找所有3和5的乘积的自然数
- c++ - 如何通过 heltec esp32 在串行监视器中读取 LoRa 消息
- wordpress - github页面上的Wordpress?
- python-3.x - 其他对象的 Python 集成
- julia - 如何在 Julia 中获取图像的属性
- ruby-on-rails - 如何在 Rails Administrate 中将 OFFSET 设置为 0?我的默认是 475
- python - 当我运行 cv2.VideoCapture() 时,Python 停止响应