pip 在安装 vpnotebook 时出错

Pip gives error when installing vpnotebook

他们的网站上没有 Vpython 版本,但根据 https://groups.google.com/forum/#!topic/vpython-users/AmIZF2v4Wkc,"pip install vpython" 应该适用于 Python 的任何版本。 我在 windows 命令提示符中输入了 "pip install vpython"。下载几分钟后,pip 给了我以下错误:

  Running setup.py install for vpnotebook ... error
    Complete output from command c:\users\zachary\appdata\local\programs\python\python36-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\Zachary\AppData\Local\Temp\pip-build-dx_wvbg0\vpnotebook\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Zachary\AppData\Local\Temp\pip-3q5u2e2l-record\install-record.txt --single-version-externally-managed --compile:
    ImportError install_kernel_spec
    c:\users\zachary\appdata\local\programs\python\python36-32\lib\site-packages\setuptools\dist.py:331: UserWarning: Normalizing '0.1.03' to '0.1.3'
      normalized_version,
    running install
    Installing Python module...
    running build
    running build_py
    creating build
    creating build\lib
    creating build\lib\vpnotebook
    copying vpnotebook\__init__.py -> build\lib\vpnotebook
    creating build\lib\vpnotebook\data
    copying vpnotebook\data\kernel.json -> build\lib\vpnotebook\data
    running install_lib
    creating c:\users\zachary\appdata\local\programs\python\python36-32\Lib\site-packages\vpnotebook
    creating c:\users\zachary\appdata\local\programs\python\python36-32\Lib\site-packages\vpnotebook\data
    copying build\lib\vpnotebook\data\kernel.json -> c:\users\zachary\appdata\local\programs\python\python36-32\Lib\site-packages\vpnotebook\data
    copying build\lib\vpnotebook\__init__.py -> c:\users\zachary\appdata\local\programs\python\python36-32\Lib\site-packages\vpnotebook
    byte-compiling c:\users\zachary\appdata\local\programs\python\python36-32\Lib\site-packages\vpnotebook\__init__.py to __init__.cpython-36.pyc
    running install_egg_info
    running egg_info
    writing vpnotebook.egg-info\PKG-INFO
    writing dependency_links to vpnotebook.egg-info\dependency_links.txt
    writing top-level names to vpnotebook.egg-info\top_level.txt
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'vpnotebook.egg-info\SOURCES.txt'
    writing manifest file 'vpnotebook.egg-info\SOURCES.txt'
    Copying vpnotebook.egg-info to c:\users\zachary\appdata\local\programs\python\python36-32\Lib\site-packages\vpnotebook-0.1.3-py3.6.egg-info
    running install_scripts
    writing list of installed files to 'C:\Users\Zachary\AppData\Local\Temp\pip-3q5u2e2l-record\install-record.txt'
    Installing custom kernel ...
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\Zachary\AppData\Local\Temp\pip-build-dx_wvbg0\vpnotebook\setup.py", line 30, in <module>
        package_data={'vpnotebook': ['data/kernel.json']},
      File "c:\users\zachary\appdata\local\programs\python\python36-32\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "c:\users\zachary\appdata\local\programs\python\python36-32\lib\distutils\dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "c:\users\zachary\appdata\local\programs\python\python36-32\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Users\Zachary\AppData\Local\Temp\pip-build-dx_wvbg0\vpnotebook\vpnotebook\__init__.py", line 72, in run
        run_kernel_install(False)
      File "C:\Users\Zachary\AppData\Local\Temp\pip-build-dx_wvbg0\vpnotebook\vpnotebook\__init__.py", line 63, in run_kernel_install
        install_kernel_spec(source_dir, kernel_name='vpython', user=user)
    NameError: free variable 'install_kernel_spec' referenced before assignment in enclosing scope

    ----------------------------------------
Command "c:\users\zachary\appdata\local\programs\python\python36-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\Zachary\AppData\Local\Temp\pip-build-dx_wvbg0\vpnotebook\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\Zachary\AppData\Local\Temp\pip-3q5u2e2l-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Zachary\AppData\Local\Temp\pip-build-dx_wvbg0\vpnotebook\

这似乎是 vpnotebook 中的错误,vpython 依赖于此。尝试在 Python 2.7 和 3.5 中安装 vpnotebook 失败并出现相同的错误,这似乎是由于包的作者甚至没有使用基本的 linter。我建议将此报告给上述作者,但是 there are no contact details, repositories, or project websites listed on the package's PyPI page.

直接解决方法是在安装 vpnotebook 之前安装 jupyter:

pip install jupyter

感谢您报告此事;在未来的问题发布在指定的位置@user1114907 或主要 github 回购:https://github.com/BruceSherwood/vpython-jupyter/issues

如果您的 python 版本大于 2.7.9,请跳至步骤 3

  1. 安装python版本>2.7.9[2.7.14为最新]

    • 下载最新版本python
    • 解压存档
    • ./configure
    • make
    • make install
  2. 下载并重新安装 pip

    • curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
    • sudo python get-pip.py
  3. 先安装jupyter

    • sudo pip install jupyter
  4. 然后,安装vpython

    • sudo pip install vpython

Post-installation Screenshot