sda*_*aau 7 python pip mingw-w64 windows-10
我试图在 Windows 10 机器上通过 MSYS2 shell 安装 Jupyter(根据https://jupyter.org/install,“使用 pip 安装 Jupyter”) - 并且进程崩溃了;然后我发现了这个:
jupyter notebook 无法启动 · Issue #1540 · msys2/MSYS2-packages · GitHub
您需要从 mingw64 shell 启动 jupyter notebook,而不是从 msys2 shell。对我来说,一个简单的 jupyter 笔记本可以按预期工作。
好的,所以我想尝试 MINGW64 shell。
请注意,在 MSYS2 外壳中:
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
Run Code Online (Sandbox Code Playgroud)
因此,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
Run Code Online (Sandbox Code Playgroud)
注意上面MINGW64 shell中python的路径;如果我们尝试查看 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
Run Code Online (Sandbox Code Playgroud)
无论如何 - 我可以在 Windows 10 上的 MINGW64 shell 中使用pipfor 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'
Run Code Online (Sandbox Code Playgroud)
使用 Mingw-64,pip 在包的下游被修补。要安装软件包,请运行:
pacman -S mingw-w64-x86_64-python-pip
然后,您应该能够使用 安装 jupyter 和其他软件包python -m pip,但避免运行,python -m pip --upgrade pip因为这会覆盖打包版本。
我还建议通过运行python -m venv .venv和source .venv/bin/activate保持 pip 安装的软件包完全独立来使用 virtualenv 。