简体   繁体   English

基本问题:Django + Python Virtual Env + pyCharm 和 CLI——是否需要两个独立的虚拟环境?

[英]Fundamentals question: Django + Python Virtual Env + pyCharm and CLI -- are two separate virtual environments required?

Bottom Line: I can get everything to work by configuring two separate virtual environments, one for pyCharm and one for the CLI.底线:我可以通过配置两个单独的虚拟环境来让一切正常工作,一个用于 pyCharm,另一个用于 CLI。 Is this really necessary or should I be able to use 1 virtual environment for both as I expected?这真的有必要吗,还是我应该能够像预期的那样同时使用 1 个虚拟环境?

More Detailed explanation:更详细的解释:

I'm very new so this is probably a facepalm type of question so i'll try to be terse.我很新,所以这可能是一个facepalm类型的问题,所以我会尽量简洁。 I'm using Linux Mint, Python 3.6, django 3.0.3, and pyCharm 2019.3.1.我使用的是 Linux Mint、Python 3.6、django 3.0.3 和 pyCharm 2019.3.1。

I can create a virtual env using venv in the cli and it works.我可以在 cli 中使用 venv 创建一个虚拟环境,它可以工作。
I can also create a NEW virtual env in pyCharm through the settings: Project: Interpreter interface, and it works, however it doesn't have venv as an option, it only has virtualenv.我还可以通过设置在 pyCharm 中创建一个新的虚拟环境:项目:解释器界面,它可以工作,但是它没有 venv 作为选项,它只有 virtualenv。

But if I try to activate the virtual env i created in pyCharm from the cli (using virtualenv of course, not venv), it fails hard and thinks i'm using python 2.7 which isn't even installed on my system.但是,如果我尝试从 cli 激活我在 pyCharm 中创建的虚拟环境(当然是使用 virtualenv,而不是 venv),它会失败并认为我使用的是 python 2.7,它甚至没有安装在我的系统上。 If it try to point pyCharm at the virtual env I setup on the cli, I get an error 134.如果它尝试将 pyCharm 指向我在 cli 上设置的虚拟环境,我会收到错误 134。

Is this just a known/expected issue?这只是一个已知/预期的问题吗? Must I have two virtual environments for every project I want to access via both pyCharm AND the cli?对于我想通过 pyCharm 和 cli 访问的每个项目,我必须有两个虚拟环境吗? And I assume this is unrelated but I also find it odd that pyCharm lists my interpreter as python 3.7, which also is not installed on my system.我认为这无关紧要,但我也觉得奇怪的是 pyCharm 将我的解释器列为 python 3.7,它也没有安装在我的系统上。 I'm using 3.6 alone.我单独使用 3.6。

Thanks for your time.谢谢你的时间。

此时,我将回答这个问题:您需要为每个(pyCharm 和 CLI)单独的虚拟环境,因为这种方法既不困难也不耗时,而且我在以这种方式工作时没有遇到任何问题。

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

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