virtualenv 没有激活虚拟环境

virtualenv not activating the virtual enviroment

我刚开始使用virtualenv,对它的了解并不深入。我按照网站上的说明创建了文件夹,然后执行了 activate.ps1 文件。它执行时没有任何错误,但是当我尝试使用 python 时,它仍在使用我系统中安装的 python,而不是虚拟环境文件夹中的那个。以下是我使用的命令:

PS A:\Code\IIITH\image-processing-iiith\SRIP> virtualenv venv
Using base prefix 'c:\users\shind\appdata\local\programs\python\python37'
New python executable in A:\Code\IIITH\image-processing-iiith\SRIP\venv\Scripts\python.exe
Installing setuptools, pip, wheel...
done.
PS A:\Code\IIITH\image-processing-iiith\SRIP> powershell -ExecutionPolicy ByPass -File venv\Scripts\activate.ps1
PS A:\Code\IIITH\image-processing-iiith\SRIP> python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import sys
>>> os.path.dirname(sys.executable)
'C:\Users\shind\AppData\Local\Programs\Python\Python37'

我使用 powershell -ExecutionPolicy ByPass -File venv\Scripts\activate.ps1 命令执行 activate.ps1 因为正常执行它,我遇到了一些安全错误。那么,我做错了什么?打印的可执行文件的路径是我系统中的路径,而它应该是 venv 文件夹中的可执行文件。此外,在 pip install 任何包裹上,它表示满足要求。我应该怎么做才能激活环境?

我正常执行文件时遇到的错误是:

PS A:\Code\IIITH\image-processing-iiith\SRIP>  venv\Scripts\activate.ps1
venv\Scripts\activate.ps1 : File A:\Code\IIITH\image-processing-iiith\SRIP\venv\Scripts\activate.ps1 cannot be loaded
because running scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:2
+  venv\Scripts\activate.ps1
+  ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

设置和使用虚拟环境:

PS /> python -m venv .venv
PS /> Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force
PS /> ./.venv/Scripts/Activate.ps1
(.venv) PS /> pip install -r requirements.txt

[...]

(.venv) PS />