【问题标题】:Add autopep8 and linting to jupyter in VS code python notebook在 VS code python notebook 中将 autopep8 和 linting 添加到 jupyter
【发布时间】:2020-06-21 22:17:22
【问题描述】:

问题

错误突出显示和自动格式化是帮助人们创建出色笔记本的绝佳工具。我正在尝试更改 VS 代码上的设置,以允许我在我的 python 笔记本中自动格式化为 pep8。

this page for Jupiter notebooks 上发现我必须在 .json 文件中的 settings>preference of VSCode 中添加一些行才能执行此操作。我对将我的代码更改为 pep8 编码约定以及添加 linting 以突出显示错误特别感兴趣。

  1. linting (error highlighting)
  2. autoformatting (autopep8)

我在 Ubuntu 18.04 上使用 VS Code。以下是我的尝试导致错误“不支持或定义代码语言”。

尝试

在VS代码中安装Python扩展和autopep8扩展并运行后

pip3 install autopep8

我收到一条错误消息,无法使用 pep8。

如果您知道如何在 VS Code 中为 Jupyter 笔记本设置高效的工作环境,我将非常感谢您的帮助

总结

如何设置:

  1. linting (error highlighting)
  2. autoformatting (autopep8)

在 Python 笔记本的 VS 代码中。

编辑 1:

我也尝试在命令面板中运行 autopep8 并得到错误

Command 'autopep8' resulted in an error (Running the contributed command: 'extension.sayHello' failed.)

【问题讨论】:

    标签: python visual-studio visual-studio-code jupyter-notebook autopep8


    【解决方案1】:

    Nbextensions 是笔记本扩展,只能在笔记本本身内使用。 VS Code 不支持本机笔记本,因此这些扩展在当时不起作用。他们计划在未来的版本中添加它link

    【讨论】:

      猜你喜欢
      • 2022-10-17
      • 2019-05-17
      • 1970-01-01
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-03
      相关资源
      最近更新 更多