【问题标题】:VS Code - Error in installing autopep8 with Conda/PipVS Code - 使用 Conda/Pip 安装 autopep8 时出错
【发布时间】:2020-01-26 06:31:16
【问题描述】:

在我的 VS Code 中,我运行了 Python 扩展,安装了 Python 3.6.1 和 Anaconda3。当我复制并粘贴一些代码时,VS Code 要求我安装 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'

我不明白消息的含义。谁能帮帮我?

注意:这是我在 PATH 中包含的所有路径:

【问题讨论】:

    标签: python visual-studio-code anaconda conda


    【解决方案1】:

    好的,我想出了解决这个问题的方法。根本原因是我的 Powershell 未配置为允许脚本在我的系统中运行。如果有人也遇到此问题,请按照以下步骤操作:

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

    【讨论】:

      【解决方案2】:

      您在 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.
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-08-28
        • 2015-10-08
        • 2021-01-23
        • 2020-04-06
        • 2017-06-20
        • 2016-11-02
        • 2019-06-14
        相关资源
        最近更新 更多