PowerShell can be said to be an upgraded version of CMD, it will be completed, copy and paste is also very convenient, the specific differences are not explained here.
Recently, a python virtual environment was set up under Windows for development and testing. At the beginning, CMD can successfully enter the virtual environment for testing. Once switched to PowerShell, the virtual environment cannot be entered.
Cannot enter the virtual environment
solution:
You need to run PowerShell as an administrator and then execute the command:
Set-ExecutionPolicy RemoteSigned
Then select Y to successfully set
At first, I forgot to open it as an administrator. As a result, the statement could not be executed:
Open as an administrator:
Whether it is started by an administrator is as follows:
Enter the virtual environment again after setting, success!
note
Sometimes you will encounter this situation. When you start the virtual environment, enter a+tab in the Scripts directory to automatically complete'.\activate.bat'.
If so, press Enter and find that there is no response and you did not successfully enter the virtual environment. , The problem is that you do not need to add a suffix to start the virtual environment:
PS E:\project\facebook\venv\Scripts> .\activate.bat # 执行该语句未响应
PS E:\project\facebook\venv\Scripts> .\activate
(venv) PS E:\project\facebook\venv\Scripts>