【问题标题】:Impossible to run jupyter-book command after installing it安装后无法运行 jupyter-book 命令
【发布时间】:2021-11-20 16:47:36
【问题描述】:

我正在尝试使用 Jupyter-book 从我的输出中创建自动 PDF,但是在使用“pip install -U jupyter-book”命令(成功运行)安装它之后,它无法识别 jupyter-book当我尝试运行命令时:

输入:

jupyter_book create Jupyter_Book_Name

输出:

SyntaxError: invalid syntax (Temp/ipykernel_16888/3781613275.py, line 1)
  File "C:\Users\MAXIME~1.DUS\AppData\Local\Temp/ipykernel_16888/3781613275.py", line 1
    jupyter_book create Jupyter_Book_Name
                 ^
SyntaxError: invalid syntax

我已经尝试在 sys.path 中添加 init jupyter_book 函数,但我得到了同样的错误,并且任何命令都会出现错误。我在 Windows 10 上的 Visual Studio Code 中使用 Jupyter Notebook 在 Python 3.9.7 中工作。

提前谢谢你,任何帮助都会帮助我。

【问题讨论】:

    标签: python jupyter-notebook jupyterbook


    【解决方案1】:

    看起来您将 shell (bash / ...) 与 Python REPL 混淆了。

    您正在 Python 解释器中运行 shell 命令,有点像您尝试通过在 Python 解释器中键入 python 来启动 Python:

    $ python   # Here I'm in bash, I run Python
    Python 3.9.7 (default, Sep  3 2021, 06:18:44) 
    >>> python  # Here I'm in the Python interpreter
                # typing python again...
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    NameError: name 'python' is not defined
    # Yup, calling `python` here make no sense, Python looks for a variable
    # named `python` not a program named `python`, and won't find it.
    

    所以退出 Python 解释器,找到一个 shell(取决于您的操作系统),然后再次运行该命令。

    哦,虽然我在这里,但可能不是:

    jupyter_book create Jupyter_Book_Name
    

    但是:

    jupyter-book create Jupyter_Book_Name
    

    【讨论】:

    • 感谢您的回复。我通过shell尝试了该命令,但效果不佳。我得到:“jupyter-book 不被识别为内部或外部命令”,所以也不被识别。我必须在路径中放置一些东西吗?
    • 我从不手动弄乱我的 PATH,但我确实使用了 venvs(当你激活它们时,它们会将自己插入到 PATH 中)。您可以尝试在 venv 中安装 jupyter-book 吗?
    • 有效!非常感谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-25
    • 1970-01-01
    • 1970-01-01
    • 2019-09-01
    • 2011-08-29
    • 1970-01-01
    相关资源
    最近更新 更多