Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pip on MINGW64?

I was trying to install Jupyter via MSYS2 shell on a Windows 10 machine (as per https://jupyter.org/install, "Installing Jupyter with pip") - and the process crashed; then I found this:

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.

Ok, so I wanted to try the MINGW64 shell.

Note, in the 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

So, pip works fine in MSYS2 shell. But if I try 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

Note the paths of python above in MINGW64 shells; if we try to see what is the path of Python in MSYS2, it is different:

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

Anyways - can I use pip for python in MINGW64 shell on Windows 10, and if so - how?


EDIT: Just tried installing pip with python3 in MINGW64 - does not work:

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'
like image 362
sdaau Avatar asked Jul 08 '19 07:07

sdaau


People also ask

How do I get pip in Python?

Ensure you can run pip from the command lineRun python get-pip.py . 2 This will install or upgrade pip. Additionally, it will install setuptools and wheel if they're not installed already. Be cautious if you're using a Python install that's managed by your operating system or another package manager.

Does pip work with Visual Studio?

Yep! Go to Tools -> Python Tools -> Python Environments . This will open a new pane where you can select pip (VS 2015) or Packages (VS 2017) from the menu (it will say Overview by default) and then you can enter your module and double click to install.

Does pip use PyPI?

Using a Custom Package Index. By default, pip uses PyPI to look for packages.


1 Answers

With Mingw-64, pip is patched downstream in the package. To install the package run: pacman -S mingw-w64-x86_64-python-pip

You should then be able to install jupyter and other packages using python -m pip, but avoid running python -m pip --upgrade pip because that will overwrite the packaged version.

I would also recommend using a virtualenv by running python -m venv .venv and source .venv/bin/activate to keep the pip installed packages completely separate.

like image 62
Dan Yeaw Avatar answered Sep 21 '22 07:09

Dan Yeaw