Python VS代码-使用Conda/Pip安装autopep8时出错

Python VS代码-使用Conda/Pip安装autopep8时出错,python,visual-studio-code,anaconda,conda,Python,Visual Studio Code,Anaconda,Conda,在我的VS代码中,我运行了Python扩展,安装了Python 3.6.1和Anaconda3。当我复制并粘贴一些代码时,VS代码要求我安装autopep8。当我按“是”时,它会显示一个框,如下所示 . 首先,我选择了“使用Conda安装”。下一步,弹出以下错误消息,无法正确安装autopep8: PS D:\Python> conda activate base CommandNotFoundError: Your shell has not been properly config

在我的VS代码中,我运行了Python扩展,安装了Python 3.6.1和Anaconda3。当我复制并粘贴一些代码时,VS代码要求我安装autopep8。当我按“是”时,它会显示一个框,如下所示 .

首先,我选择了“使用Conda安装”。下一步,弹出以下错误消息,无法正确安装autopep8:
PS D:\Python> conda activate base

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If using 'conda activate' from a batch script, change your
invocation to 'CALL conda.bat activate'.

To initialize your shell, run

    $ conda init <SHELL_NAME>

Currently supported shells are:
  - bash
  - cmd.exe
  - fish
  - tcsh
  - zsh
  - powershell

See 'conda init --help' for more information and options.

IMPORTANT: You may need to close and restart your shell after running 'conda init'.


PS D:\Python> & conda install --name base autopep8
Collecting package metadata (current_repodata.json): failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/main/win-64/current_repodata.json>
Elapsed: -

An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.

If your current network has https://www.anaconda.com blocked, please file
a support request with your network engineering team.

'https://repo.anaconda.com/pkgs/main/win-64'
PS D:\Python>conda激活基
CommandNotFoundError:您的shell未正确配置为使用“conda activate”。
如果使用批处理脚本中的“conda activate”,请更改
调用“调用conda.bat激活”。
要初始化shell,请运行
$conda init
当前支持的shell有:
-猛击
-cmd.exe
-鱼
-tcsh
-zsh
-动力壳
有关更多信息和选项,请参阅“conda init--help”。
重要提示:在运行“conda init”后,您可能需要关闭并重新启动shell。
PS D:\Python>&conda安装--name base autopep8
收集包元数据(current_repodata.json):失败
CondaHttPeror:url的HTTP 000连接失败
已过去:-
尝试检索此URL时发生HTTP错误。
HTTP错误通常是断断续续的,一次简单的重试就可以让您上路。
如果您当前的网络https://www.anaconda.com 已阻止,请存档
网络工程团队的支持请求。
'https://repo.anaconda.com/pkgs/main/win-64'

我不明白这个信息是什么意思。有人能帮我吗

注意:以下是我在路径中包含的所有路径:
好的,我想出了这个问题的解决办法。根本原因是我的Powershell未配置为允许脚本在我的系统中运行。如果任何人也有此问题,请执行以下步骤:

  • 以管理员身份启动Powershell
  • Set ExecutionPolicy-ExecutionPolicy Unrestricted
    并选择
    Y
  • 在Powershell中,键入
    conda init Powershell
    并运行
  • 重新打开VS代码。然后在.py文件中复制并粘贴一些Python代码
  • 在右下角,VS代码将询问是否安装autopep8。选择是
  • VS代码将自动运行一些Powershell命令。现在应该可以了

  • 您在conda下的安装失败,因为您尚未将shell设置为使用conda。有关如何设置此项的说明在错误消息中稍有下降:

    To initialize your shell, run
    
        $ conda init <SHELL_NAME>
    
    Currently supported shells are:
      - bash
      - cmd.exe
      - fish
      - tcsh
      - zsh
      - powershell
    
    See 'conda init --help' for more information and options.
    
    要初始化shell,请运行
    $conda init
    当前支持的shell有:
    -猛击
    -cmd.exe
    -鱼
    -tcsh
    -zsh
    -动力壳
    有关更多信息和选项,请参阅“conda init--help”。