Cygwin Installing Python Modules

Installing Python Modules. Of a standard Python installation by building and installing third-party Python modules and extensions. GNU C / Cygwin / MinGW.

Active3 years, 3 months ago

While I am aware of the option of installing Pip from source, I'm trying to avoid going down that path so that updates to Pip will be managed by Cygwin's package management.

I've recently learned that the latest versions of Python include Pip. However, even though I have recently installed the latest versions of Python from the Cygwin repos, Bash doesn't recognize a valid Pip install on the system.

Note that the installed Python 2.7.10 and Python 3.4.3 are both recent enough that they should include Pip.

Is there something that I might have overlooked? Could there be a new install of Pip that isn't in the standard binary directories referenced in the $PATH? If the Cygwin packages of Python do in fact lack an inclusion of Pip, is that something that's notable enough to warrant a bug report to the Cygwin project?

Community
redyoshi49qredyoshi49q

2 Answers

cel self-answered this question in a comment above. For posterity, let's convert this helpfully working solution into a genuine answer.

Unfortunately, Cygwin currently fails to:

Running Python In Cygwin

  • Provide pip, pip2, or pip3 packages.
  • Install the pip and pip2 commands when the python package is installed.
  • Install the pip3 command when the python3 package is installed.

It's time to roll up our grubby command-line sleeves and get it done ourselves.

Cygwin Installing Python Modules

What's the Catch?

Since nopip packages are currently available, the answer to the specific question of 'Is pip installable as a Cygwin package?' is technically 'Sorry, son.'

That said, pipis trivially installable via a one-liner. This requires manually re-running said one-liner to update pip but has the distinct advantage of actually working. (Which is more than we usually get in Cygwin Land.)

pip3 Installation, Please

To install pip3, the Python 3-specific version of pip, under Cygwin:

This assumes the python3 Cygwin package to have been installed, of course.

Cygwin Install Python

pip2 Installation, Please

To install both pip and pip2, the Python 2-specific versions of pip, under Cygwin:

Cygwin Python 3.5

This assumes the python Cygwin package to have been installed, of course.

Cecil CurryCecil Curry
5,5202 gold badges25 silver badges27 bronze badges
  1. Download a helper package:

    • For Python 2.x install the python-setuptools package.
    • For Python 3.x install the python3-setuptools package.
  2. Run the script:

    • For Python 2.7 run: easy_install-2.7 pip
    • For Python 3.4 run: easy_install-3.4 pip
moovon

Cygwin Install Python 2.7

moovon
1,5851 gold badge11 silver badges10 bronze badges

Not the answer you're looking for? Browse other questions tagged pythoncygwinpip or ask your own question.

This tutorial shows how to develop C++ modules that can be loaded into Python scripts under Cygwin. The Cygwin environment contains Windows ports for many Linux-based tools, so if you are porting a Linux application to run on Windows, it can prove time-saving by drastically reducing the porting effort. It also comes with pre-built Python 2.x and 3.x and we will show in this tutorial how to create a module that will be loaded into a Cygwin Python script.

Before you begin, install VisualGDB 5.1 or later and install Cygwin including the following packages:

  • g++
  • gdb
  • make
  • python3
  • python3-debuginfo

Cygwin Install Python Modules

  1. Start Visual Studio and launch the VisualGDB MinGW/Cygwin Project Wizard:
  2. Select “Create a new project -> A Cygwin Python module”:
  3. Select the location of your Cygwin toolchain. If it’s not auto-detected, select “specify a Cygwin-based toolchain manually” and point VisualGDB to its location:
  4. On the last page of the wizard replace “python” with “python3” to explicitly select Python 3.x and press “Finish”:
  5. VisualGDB will create a project consisting of a C++ Python module, a Makefile building the module using the Python includes and libraries and a simple Python script calling a function from the module. Build the module by pressing Ctrl-Shift-B:
  6. Set a breakpoint in the Python script on the line calling the hello() method and press F5 to start debugging. Once the breakpoint hits you will be able to look through the Python variables or step through the code:
  7. If you step into the hello() method, VisualGDB will actually step into the internal Python function used to call C++ functions, so instead, set a breakpoint in the HelloMethod() and press F5. Once the breakpoint hits, you will see both C++ and Python frames in the Call Stack and will be able to step through the method:
  8. You can navigate the Call Stack to view the Python code calling the C++ code and even the internal Python interpreter’s functions responsible for handling the calls. This is especially useful when debugging complex memory corruption problems:
  9. Set a breakpoint on the print() line and resume debugging. Once the breakpoint is hit, see that the Python script has received the value of 123 returned by the C++ method: