【问题标题】:Cannot install jupyter on windows: No module named '_pyrsistent_version'无法在 Windows 上安装 jupyter:没有名为“_pyrsistent_version”的模块
【发布时间】:2020-05-24 21:22:56
【问题描述】:

我在 Windows 7 SP1 x64 中使用 "Windows x86-64 embeddable zip file" python 3.7.3 distribution 来运行 Python。我添加了 pip 脚本,它正在工作。

我尝试使用 pip 安装 jupyter 1.0.0。发生此错误:

C:\Users\user\Downloads\python-3.7.3-embed-amd64>Scripts\pip.exe install jupyter
Collecting jupyter
  Using cached jupyter-1.0.0-py2.py3-none-any.whl (2.7 kB)
Collecting ipykernel
  Using cached ipykernel-5.1.4-py3-none-any.whl (116 kB)
.
.
[SUMMARIZED]
.
.
Collecting pywinpty>=0.5; os_name == "nt"
  Using cached pywinpty-0.5.7-cp37-cp37m-win_amd64.whl (1.3 MB)
Collecting parso>=0.5.2
  Using cached parso-0.6.1-py2.py3-none-any.whl (97 kB)
Collecting pyrsistent>=0.14.0
  Using cached pyrsistent-0.15.7.tar.gz (107 kB)
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\user\downloads\python-3.7.3-embed-amd64\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-mvod9jy8\\pyrsistent\\setup.py'"'"'; __file__='"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-mvod9jy8\\pyrsistent\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\user\AppData\Local\Temp\pip-install-mvod9jy8\pyrsistent\pip-egg-info'
         cwd: C:\Users\user\AppData\Local\Temp\pip-install-mvod9jy8\pyrsistent\

    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\user\AppData\Local\Temp\pip-install-mvod9jy8\pyrsistent\setup.py", line 10, in <module>
        from _pyrsistent_version import __version__
    ModuleNotFoundError: No module named '_pyrsistent_version'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

然后我尝试安装pyrsistent 0.15.7。发生了同样的错误:

C:\Users\user\Downloads\python-3.7.3-embed-amd64>Scripts\pip.exe install pyrsistent
Collecting pyrsistent
  Using cached pyrsistent-0.15.7.tar.gz (107 kB)
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\user\downloads\python-3.7.3-embed-amd64\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-ssyijah2\\pyrsistent\\setup.py'"'"'; __file__='"'"'C:\\Users\\user\\AppData\\Local\\Temp\\pip-install-ssyijah2\\pyrsistent\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\user\AppData\Local\Temp\pip-install-ssyijah2\pyrsistent\pip-egg-info'
         cwd: C:\Users\user\AppData\Local\Temp\pip-install-ssyijah2\pyrsistent\

    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\user\AppData\Local\Temp\pip-install-ssyijah2\pyrsistent\setup.py", line 10, in <module>
        from _pyrsistent_version import __version__
    ModuleNotFoundError: No module named '_pyrsistent_version'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

如何安装 jupyter 并修复此错误?

【问题讨论】:

    标签: python windows pip jupyter-notebook python-embedding


    【解决方案1】:
    1. 从Download Files section下载pyrsistent 0.15.7源文件。
    2. 将存档解压到一个文件夹中(在本例中为C:\Users\user\Downloads\pyrsistent-0.15.7)
    3. 在文本编辑器中打开setup.py。评论line 10:

      # from _pyrsistent_version import __version__
      

      然后从这里更改line 54:

          version=__version__,
      

      到这里:

          version='0.15.7',
      
    4. 使用 pip 从修改后的源安装 pyrsistent:

      C:\Users\user\Downloads\python-3.7.3-embed-amd64>Scripts\pip.exe install ..\pyrsistent-0.15.7
      Processing c:\users\user\downloads\pyrsistent-0.15.7
      Requirement already satisfied: six in c:\users\user\downloads\python-3.7.3-embed-amd64\lib\site-packages (from pyrsistent==0.15.7) (1.12.0)
      Building wheels for collected packages: pyrsistent
        Building wheel for pyrsistent (setup.py) ... done
        Created wheel for pyrsistent: filename=pyrsistent-0.15.7-cp37-cp37m-win_amd64.whl size=56531 sha256=ae2ae62129ecd2aba69353b2cc335a23cbf53024a1ac211d01c1d792f465f0b0
        Stored in directory: c:\users\user\appdata\local\pip\cache\wheels\ea\5a\2e\b0e3bb620adcd5a9a0d22e143161ab87ee02da6eb86e4b3657
      Successfully built pyrsistent
      Installing collected packages: pyrsistent
      Successfully installed pyrsistent-0.15.7
      
    5. 使用 pip 安装 jupyter:
      C:\Users\user\Downloads\python-3.7.3-embed-amd64>Scripts\pip.exe install jupyter
      Collecting jupyter
        Using cached jupyter-1.0.0-py2.py3-none-any.whl (2.7 kB)
      Collecting ipykernel
        Using cached ipykernel-5.1.4-py3-none-any.whl (116 kB)
      .
      .
      [SUMMARIZED]
      .
      .
      Successfully installed MarkupSafe-1.1.1 Send2Trash-1.5.0 backcall-0.1.0 bleach-3.1.0 colorama-0.4.3 decorator-4.4.1 defusedxml-0.6.0 entrypoints-0.3 importlib-metadata-1.5.0 ipykernel-5.1.4 ipython-7.12.0 ipython-genutils-0.2.0 ipywidgets-7.5.1 jedi-0.16.0 jinja2-2.11.1 jsonschema-3.2.0 jupyter-1.0.0 jupyter-client-5.3.4 jupyter-console-6.1.0 jupyter-core-4.6.1 mistune-0.8.4 nbconvert-5.6.1 nbformat-5.0.4 notebook-6.0.3 pandocfilters-1.4.2 parso-0.6.1 pickleshare-0.7.5 prometheus-client-0.7.1 prompt-toolkit-3.0.3 pygments-2.5.2 pywin32-227 pywinpty-0.5.7 pyzmq-18.1.1 qtconsole-4.6.0 terminado-0.8.3 testpath-0.4.4 tornado-6.0.3 traitlets-4.3.3 wcwidth-0.1.8 webencodings-0.5.1 widgetsnbextension-3.5.1 zipp-2.2.0
      

    【讨论】:

      【解决方案2】:

      同样的问题也发生在我身上。 我的解决方案:

      1. 安装 pip 后,
      2. 下载pyrsistent 0.15.7
      3. 解压并将“_pyrsistent_version.py”复制到 %pythoninstallationdir%/Lib/site-packages(注意,%pythoninstallationdir% 只是安装目录的路径,无论它在哪里,它可能不完全是环境变量)
      4. 验证文件 %pythoninstallationdir%/python38._pth 中是否有“./lib/site-packages”行。
      5. 安装jupyter:python -m pip install jupyter
      6. 您现在可以使用jupyter notebook 运行笔记本

      请注意,您只是“伪造”python 以为一切都很好并且您安装了 jupyter,但是如果您希望稍后对您的 python 安装执行任何可能实际需要 pyrsistent 模块的操作,您应该现在安装它。 在 setup.py 中,将第 54 行从 version=__version__ 更改为 version='0.15.7',如另一个答案中所述。安装现在应该可以使用例如:

      python -m pip install ./pyrsistent-0.15.7
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-05-16
        • 1970-01-01
        • 2022-06-27
        • 2019-05-05
        • 1970-01-01
        • 2019-04-15
        • 2021-02-10
        • 1970-01-01
        相关资源
        最近更新 更多