在 MINGW64 上点子?

Pip on MINGW64?

我试图通过 MSYS2 shell 在 Windows 10 机器上安装 Jupyter(根据 https://jupyter.org/install、"Installing Jupyter with pip")- 进程崩溃了;然后我发现了这个:

jupyter notebook fails to start · Issue #1540 · msys2/MSYS2-packages · GitHub

You need to start jupyter notebook from the mingw64 shell, not from the msys2 shell. For me a simple jupyter notebook works as expected.

好的,所以我想试试 MINGW64 shell。

注意,在 MSYS2 shell:

user@DESKTOP-PC MSYS /c/
$ python3 -m pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/5c/e0/be401c003291b56efc55aeba6a80ab790d3d4cece2778288d65323009420/pip-19.1.1-py2.py3-none-any.whl (1.4MB)
     |████████████████████████████████| 1.4MB 2.3MB/s
Installing collected packages: pip
  Found existing installation: pip 19.1
    Uninstalling pip-19.1:
      Successfully uninstalled pip-19.1
Successfully installed pip-19.1.1

因此,pip 在 MSYS2 shell 中工作正常。但是如果我尝试 MINGW64:

user@DESKTOP-PC MINGW64 ~
$ python3 -m pip install jupyter
C:/msys64/mingw64/bin/python3.exe: No module named pip

user@DESKTOP-PC MINGW64 ~
$ python2 -m pip install --upgrade pip
C:/msys64/mingw64/bin/python2.exe: No module named pip

注意上面python在MINGW64 shells中的路径;如果我们尝试查看 MSYS2 中 Python 的路径是什么,它是不同的:

user@DESKTOP-PC MSYS /c/
$ which python3
/usr/bin/python3

user@DESKTOP-PC MSYS /c/
$ cygpath -w `which python3`
C:\msys64\usr\bin\python3.exe

无论如何 - 我可以在 Windows 10 上在 MINGW64 shell 中将 pip 用于 python,如果可以 - 如何使用?


编辑:刚刚尝试在 MINGW64 中使用 python3 安装 pip - 不起作用:

user@PC MINGW64 /c/Users/user/Desktop
$ python3 get-pip.py
Collecting pip
  Downloading https://files.pythonhosted.org/packages/5c/e0/be401c003291b56efc55aeba6a80ab790d3d4cece2778288d65323009420/pip-19.1.1-py2.py3-none-any.whl (1.4MB)
     |################################| 1.4MB 1.7MB/s
Collecting wheel
  Downloading https://files.pythonhosted.org/packages/bb/10/44230dd6bf3563b8f227dbf344c908d412ad2ff48066476672f3a72e174e/wheel-0.33.4-py2.py3-none-any.whl
Installing collected packages: pip, wheel
ERROR: Exception:
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Temp\tmp4b0z8ro2\pip.zip\pip\_internal\cli\base_command.py", line 178, in main
    status = self.run(options, args)
  File "C:\Users\user\AppData\Local\Temp\tmp4b0z8ro2\pip.zip\pip\_internal\commands\install.py", line 414, in run
    use_user_site=options.use_user_site,
  File "C:\Users\user\AppData\Local\Temp\tmp4b0z8ro2\pip.zip\pip\_internal\req\__init__.py", line 58, in install_given_reqs
    **kwargs
  File "C:\Users\user\AppData\Local\Temp\tmp4b0z8ro2\pip.zip\pip\_internal\req\req_install.py", line 922, in install
    use_user_site=use_user_site, pycompile=pycompile,
  File "C:\Users\user\AppData\Local\Temp\tmp4b0z8ro2\pip.zip\pip\_internal\req\req_install.py", line 448, in move_wheel_files
    warn_script_location=warn_script_location,
  File "C:\Users\user\AppData\Local\Temp\tmp4b0z8ro2\pip.zip\pip\_internal\wheel.py", line 544, in move_wheel_files
    generated.extend(maker.make(spec))
  File "C:\Users\user\AppData\Local\Temp\tmp4b0z8ro2\pip.zip\pip\_vendor\distlib\scripts.py", line 405, in make
    self._make_script(entry, filenames, options=options)
  File "C:\Users\user\AppData\Local\Temp\tmp4b0z8ro2\pip.zip\pip\_vendor\distlib\scripts.py", line 309, in _make_script
    self._write_script(scriptnames, shebang, script, filenames, ext)
  File "C:\Users\user\AppData\Local\Temp\tmp4b0z8ro2\pip.zip\pip\_vendor\distlib\scripts.py", line 245, in _write_script
    launcher = self._get_launcher('t')
  File "C:\Users\user\AppData\Local\Temp\tmp4b0z8ro2\pip.zip\pip\_vendor\distlib\scripts.py", line 384, in _get_launcher
    result = finder(distlib_package).find(name).bytes
AttributeError: 'NoneType' object has no attribute 'bytes'

你可以用pacman安装:

pacman -S python-pip

如果你需要git:

pacman -S git

对于 Mingw-64,pip 在包的下游进行了修补。要安装包 运行: pacman -S mingw-w64-x86_64-python-pip

然后您应该能够使用 python -m pip 安装 jupyter 和其他包,但避免 运行ning python -m pip --upgrade pip 因为这将覆盖打包版本。

我还建议使用 运行ning python -m venv .venvsource .venv/bin/activate 的 virtualenv 来保持 pip 安装包完全独立。