简体   繁体   English

在Pycharm中使用virtualenv跨平台(Linux和Windows)

[英]Using virtualenv cross-platform (Linux and Windows) in Pycharm

I've created a virtualenv for my project on Linux and installed the packages I need just fine. 我已经在Linux上为我的项目创建了virtualenv并安装了我需要的软件包。 When setting up my project in Pycharm, I can select the interpreter to use from venv/bin and Pycharm picks up all the packages in that virtualenv. 在Pycharm中设置项目时,我可以从venv / bin中选择要使用的解释器,然后Pycharm会选择该virtualenv中的所有软件包。

I also like to develop on a Windows machine, and I'd like to be able to use the same virtualenv I created on Linux when I clone it from git. 我也想在Windows机器上进行开发,并且我希望能够使用从git克隆Linux时所创建的相同virtualenv。 However the interpreter created by Linux is a script that runs python3 ; 但是,Linux创建的解释器是运行python3的脚本; this means I'd have to create a new Windows style virtualenv. 这意味着我必须创建一个新的Windows风格的virtualenv。

So my question is, is there a way I can create a venv that can be used cross platform? 所以我的问题是,有没有一种方法可以创建可跨平台使用的venv?

A virtualenv is specific to the platform and location it was created on. virtualenv特定于其创建所在的平台和位置。 You should not check it into version control. 您不应将其签入版本控制。 Each environment you develop in will have its own virtualenv. 您开发的每个环境都将具有自己的virtualenv。 You make your package installable with setup.py , and/or specify requirements in requirements.txt in order to recreate the virtualenv. 您可以使用setup.py将软件包安装为可安装的,和/或在requirements.txt中指定需求,以重新创建virtualenv。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM