virtualenv 问题 - 无法激活 [英] Issue with virtualenv - cannot activate

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

问题描述

我在我的项目周围创建了一个 virtualenv,但是当我尝试激活它时我不能.它可能只是语法或文件夹位置,但我现在很难过.

您可以在下面看到,我创建了 virtualenv 并将其命名为 venv.一切看起来都不错,然后我尝试通过运行 source venv/bin/activate

来激活它

我认为这可能与我的系统路径有关,但不确定要指向什么(我知道如何编辑路径).我在 python 7/windows 操作系统上,虚拟环境 2.2.x

<前>处理 virtualenv 的依赖项完成 virtualenv 的处理依赖项c:\testdjangoproj\mysite>virtualenv --no-site-packages venv--no-site-packages 标志已弃用;它现在是默认行为.使用真正的前缀 'C:\\Program Files (x86)\\Python'venv\Scripts\python.exe 中的新 python 可执行文件文件 venv\Lib\distutils\distutils.cfg 存在,内容不同;不覆盖婷安装 setuptools.................done.安装pip…………完成.c:\testdjangoproj\mysite>source venv/bin/activate'source' 未被识别为内部或外部命令,可运行的程序或批处理文件.c:\testdjangoproj\mysite>source venv/bin/activate'source' 未被识别为内部或外部命令,可运行的程序或批处理文件.c:\testdjangoproj\mysite>source mysite/bin/activate'source' 未被识别为内部或外部命令,可运行的程序或批处理文件.c:\testdjangoproj\mysite>

解决方案

source 是一个 shell 命令,专为在 Linux(或任何 Posix,但不是 Windows)上运行的用户设计.

在 Windows 上,virtualenv 创建一个 .bat/.ps1 文件,因此您应该运行 venv\Scripts\activate(根据 virtualenv 关于激活脚本的文档).

只需运行 activate,不带扩展名,因此无论您使用的是 cmd.exe 还是 PowerShell,都会使用正确的文件.

I created a virtualenv around my project, but when I try to activate it I cannot. It might just be syntax or folder location, but I am stumped right now.

You can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv/bin/activate

I'm thinking it might just have to do with my system path, but not sure what to point it to (I do know how to edit the path). I'm on python 7 / windows os, virtual env 2.2.x

Processing dependencies for virtualenv
Finished processing dependencies for virtualenv

c:\testdjangoproj\mysite>virtualenv --no-site-packages venv
The --no-site-packages flag is deprecated; it is now the default behavior.
Using real prefix 'C:\\Program Files (x86)\\Python'
New python executable in venv\Scripts\python.exe
File venv\Lib\distutils\distutils.cfg exists with different content; not overwri
ting
Installing setuptools.................done.
Installing pip...................done.

c:\testdjangoproj\mysite>source venv/bin/activate
'source' is not recognized as an internal or external command,
operable program or batch file.

c:\testdjangoproj\mysite>source venv/bin/activate
'source' is not recognized as an internal or external command,
operable program or batch file.

c:\testdjangoproj\mysite>source mysite/bin/activate
'source' is not recognized as an internal or external command,
operable program or batch file.

c:\testdjangoproj\mysite>

解决方案

source is a shell command designed for users running on Linux (or any Posix, but whatever, not Windows).

On Windows, virtualenv creates a .bat/.ps1 file, so you should run venv\Scripts\activate instead (per the virtualenv documentation on the activate script).

Just run activate, without an extension, so the right file will get used regardless of whether you're using cmd.exe or PowerShell.

这篇关于virtualenv 问题 - 无法激活的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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