Python - 为 django 项目重新激活我的 virtualenv [英] Python - Reactivating my virtualenv for django project

查看:42
本文介绍了Python - 为 django 项目重新激活我的 virtualenv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(初学者)我正在使用我的 Macos 终端和 Visual Studio Code 为 django 项目使用 virtualenv.

(Beginner) I am working with a virtualenv for a django project using my Macos terminal and Visual Studio Code.

最近,我的终端在我运行所有代码的地方消失了,我不知道如何重新进入我的 virtualenv 或我仍然在 Visual Studio Code 上的项目.我已经尝试了一切,包括:

Recently, my terminal disappeared where I was running all of my code and I do not know how to reenter my virtualenv or my project that I still have on Visual Studio Code. I have tried everything including:

source virtualenv/bin/activate 

或者,

virtualenv/source/activate 

或者,

cd my_project_name 

然后尝试使用上述命令按照此步骤 (^) 进入我的 virtualenv.

and then trying to enter my virtualenv following this step (^) with the commands above.

没有任何效果,当我运行python manage.py runserver"时;它说没有这样的文件或目录.在回到我的项目和 virtualenv 之前,我很挣扎,不知道如何在 django 上继续我当前的项目.

Nothing is working and when I run "python manage.py runserver" it says there is no such file or directory. I am struggling and do not know how to continue my current project on django before getting back to my project and virtualenv.

非常感谢任何帮助!

推荐答案

Visual Studio 代码实际上有一种方便的方式来跟踪虚拟环境.在蓝色页脚栏的最底部,点击刷新图标旁边的,您应该会看到它是否可用.

Visual studio code actually has a convenient way of keeping track of virtual environments. At the very bottom in the blue footer bar, click next to the refresh icon, and you should see whether it's available.

如果它真的消失了,请不要担心.虚拟环境是完全可以消耗的——它会出现.现在,只需创建另一个,并确保这次在项目的根目录中创建它.

If it's really gone, don't sweat it. Virtual environments are completely expendable – it'll turn up. For now, just make another, and be sure you create it in your project's root directory this time.

您实际上通常不需要使用 vscode 激活 venv.只需 cd 进入项目根目录并使用 code . 打开 vscode.激活的环境将出现在页脚的同一位置.

You actually usually don't need to activate a venv with vscode. Just cd into the project root directory and open vscode with code .. The activated envionment will appear in that same spot in the footer.

另外,考虑使用 requirements.txt 文件,如果你一直把 virtualenv 放错地方,它会节省很多时间.

Also, look into using a requirements.txt file, it'll save a lot of time if you keep misplacing the virtualenv.

最后,最好不要将您的 venv 命名为virtualenv",而是将其命名为独特的名称 - 否则肯定会造成混淆!

And finally, it's best not to name your venv "virtualenv", name it something unique – otherwise it's guaranteed to confuse!

这篇关于Python - 为 django 项目重新激活我的 virtualenv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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