今天装odoo17的过程中,指定了conda虚拟环境,打开终端的时候无法激活
PS C:\Users\Administrator> conda activate py311
usage: conda-script.py [-h] [--no-plugins] [-V] COMMAND ...
conda-script.py: error: argument COMMAND: invalid choice: 'activate' (choose from 'clean', 'compare', 'config', 'create', 'info', 'init', 'install', 'list', 'notices', 'package', 'remove', 'uninstall', 'rename', 'run', 'search', 'update', 'upgrade', 'build', 'convert', 'debug', 'develop', 'doctor', 'index', 'inspect', 'metapackage', 'render', 'skeleton', 'pack', 'content-trust', 'verify', 'token', 'env', 'repo', 'server')
后来经网友指点:“允许本地计算机允许运行本地脚本”, 也就执行了两个命令
管理员运行powershell,执行两条指令:
PS C:\WINDOWS\system32> Set-ExecutionPolicy RemoteSigned
执行策略更改
执行策略可帮助你防止执行不信任的脚本。更改执行策略可能会产生安全风险,如 https:/go.microsoft.com/fwlink/?LinkID=135170
中的 about_Execution_Policies 帮助主题所述。是否要更改执行策略?
[Y] 是(Y) [A] 全是(A) [N] 否(N) [L] 全否(L) [S] 暂停(S) [?] 帮助 (默认值为“N”): y
PS C:\WINDOWS\system32> conda init powershell
no change D:\ProgramData\anaconda3\Scripts\conda.exe
no change D:\ProgramData\anaconda3\Scripts\conda-env.exe
no change D:\ProgramData\anaconda3\Scripts\conda-script.py
no change D:\ProgramData\anaconda3\Scripts\conda-env-script.py
no change D:\ProgramData\anaconda3\condabin\conda.bat
no change D:\ProgramData\anaconda3\Library\bin\conda.bat
no change D:\ProgramData\anaconda3\condabin\_conda_activate.bat
no change D:\ProgramData\anaconda3\condabin\rename_tmp.bat
no change D:\ProgramData\anaconda3\condabin\conda_auto_activate.bat
no change D:\ProgramData\anaconda3\condabin\conda_hook.bat
no change D:\ProgramData\anaconda3\Scripts\activate.bat
no change D:\ProgramData\anaconda3\condabin\activate.bat
no change D:\ProgramData\anaconda3\condabin\deactivate.bat
modified D:\ProgramData\anaconda3\Scripts\activate
modified D:\ProgramData\anaconda3\Scripts\deactivate
modified D:\ProgramData\anaconda3\etc\profile.d\conda.sh
modified D:\ProgramData\anaconda3\etc\fish\conf.d\conda.fish
no change D:\ProgramData\anaconda3\shell\condabin\Conda.psm1
modified D:\ProgramData\anaconda3\shell\condabin\conda-hook.ps1
modified D:\ProgramData\anaconda3\Lib\site-packages\xontrib\conda.xsh
modified D:\ProgramData\anaconda3\etc\profile.d\conda.csh
modified D:\fatux\doc\WindowsPowerShell\profile.ps1
==> For changes to take effect, close and re-open your current shell. <==
然后在vs下,按ctrl+· 打开终端,大功告成!
(base) PS D:\BaiduSyncdisk\odoo\odoo17> activate
(base) PS D:\BaiduSyncdisk\odoo\odoo17> conda activate py312
(py312) PS D:\BaiduSyncdisk\odoo\odoo17>
注意: power shell 可以执行,cmd还是不行