如何从虚拟环境中获取 flake8 作为全局包和其他包? [英] How to get flake8 as a global package and other packages from virtual environment?

查看:23
本文介绍了如何从虚拟环境中获取 flake8 作为全局包和其他包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用带有 flake8 linter 的 Visual Studio Code,但我不知道如何创建一个可以访问全局安装包 (flake8) 的虚拟环境.virtualenv env --system-site-packages 不像我想要的那样工作,因为当我输入命令 pip freeze 时,它会显示所有全局包.

I use Visual Studio Code with flake8 linter but I don't know how to make a virtual environment with an access to globally installed package (flake8). virtualenv env --system-site-packages doesn't work like I would like because when I put a command pip freeze it shows me all global packages.

推荐答案

您可以设置"python.linting.flake8Path" 设置 指向您全局安装的 flake8.

You can set the "python.linting.flake8Path" setting to point to your global install of flake8.

至于将开发工具与项目的依赖项分开,几乎所有 Python 打包工具在列出依赖项时都有办法将两者分开.您还可以保留一个 requirements.txt 文件来维护您的项目的依赖项和一个 dev-requirements.txt 包含:

As for keeping your dev tools separate from project's dependencies, pretty much all packaging tools for Python have a way to separate the two when listing dependencies. You can also keep a requirements.txt file that maintains your project's dependencies and a dev-requirements.txt that contains:

-r requirements.txt
flake8

这可能是您的代码开发人员安装的来源.

and that can be what developers of your code install from.

这篇关于如何从虚拟环境中获取 flake8 作为全局包和其他包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆