Cygwin Installing Python Modules

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. This document describes the Python Distribution Utilities (“Distutils”) from the end-user’s point-of-view, describing how to extend the capabilities of a standard Python installation by building and installing third-party Python modules and extensions. While installing cygwin, make sure you install the python/python-setuptools from the list. This will install 'easy_install' package. Once you have easy_install, you can use it to install pip.

Active6 years, 11 months ago

I've been using Cygwin on Windows recently. I want to use the Windows installation of Python, so during testing I'm using /cygdrive/c/Python26/python.exe myfile.py rather than python myfile.exe.

CygwinCygwin Installing Python Modules

This is working almost perfectly, except for printing. When I run the Windows Python from Cygwin the output doesn't print until execution finishes. It works fine running in Windows Python from explorer.exe or cmd.exe, and it works in Cygwin using the Cygwin-installed Python (/bin/python.exe).

Is there a workaround for this? The important thing is to be able to run the Windows version, but I'd like to do it all from with Bash.

SkilldrickSkilldrick
52.8k32 gold badges160 silver badges224 bronze badges

3 Answers

AmroAmro
117k21 gold badges218 silver badges403 bronze badges

The real problem is that when you run a command in any of the Cygwin terminal programs like mintty, they don't act as Windows Consoles. Only Windows Console-based ones like CMD or Console2 do that. So, with Cygwin terminals the Windows python.exe doesn't think it is talking to an interactive console.

That leads to buffering output instead of flushing buffers on every line as is done in interactive sessions. That is why Amro's adding the flush() on every line fixes the symptom, but means changing the code.

One solution without changing the code is to turn off buffering in Python using the '-u' flag on the command line or setting the PYTHONUNBUFFERED environment variable.

or

or run in interactive mode

Cygwin Install Python Package

You will also not be able to run the Windows python.exe interactive mode in the Cygwin terminal. It will not bring up an interactive session, but will just hang. I find the best solution seems to be to use 'cygstart' (better than using the '-i' option):

Act 1 Missions. Table of Contents. Saints Row 3 Wiki Guide. Act 1 Missions. Act 1 Missions. When Good Heists Go Bad. I'm Free - Free Falling We're Going To Need Guns. CGC Huge Poster - Saints Row 3 The Third PS3 XBOX 360 PC - SSR006 (24' x 36' (61cm x 91.5cm)) by Saints Row. $16.95 $ 16 95. FREE Shipping on eligible orders. Only 2 left in stock - order soon. Product Features FREE delivery within US. Receive it in 3 business days. Previous Page 1 2 3. Show results for. Saints row 3 pc s. Saints Row Select A Language. Enter Date of Birth The cookies we use are intended to ensure that you can enjoy our website in the best possible way. Game: Saints Row 3. When logged in. Ever since Monster Hunter World released on PC in August of this year, we have been very proud to host the modding community for one of Capcom's most popular games of all time. Deliverance, The Witcher 3 or Battletech there's no time like the present. Check out the Nexus Mods Winter Collection for our. Saints Row The Third Free Download for PC – Released on November 15, 2011, Saints Row The Third is a open world action adventure game published by THQ. It is the third game in the series. Learn how to download and Install Saints Row The Third for free in this article and be sure to share with your friends.

And that seems to work with ipython as well (if installed):

noisygeckonoisygecko
1,5463 gold badges12 silver badges13 bronze badges

Not answering the initial question, but for those who want to use Python interactive session from within Cygwin terminal (for example in mintty) - start Python with '-i' option to tell it explicitly that it needs to run in interactive mode:

Unzip the contents of the archive, run the trainer, and then the game. Extra care should be taken with modifications, trainers, and other things that were not created by the game’s developers. Kingdoms of amalur reckoning collections. Note: The cheats and tricks listed above may not necessarily work with your copy of the game. This is due to the fact that they generally work with a specific version of the game and after updating it or choosing another language they may (although do not have to) stop working or even malfunction.

The neat way is also to create an alias in your .bashrc (knowing that it is only read for interactive terminal sessions anyway):

Otherwise, Python will not know that it runs in the console, because all Cygwin pty-based terminals (mintty, rxvt and xterm) are recognized as pipes by Windows, not as the console. Therefore, Python thinks there is no console and enters non-interactive mode. So, if you still want interactive mode instead, you need to explicitly tell Python to use it. However, it still won't behave as it normally should - one still won't be able to use HOME or LEFT ARROW keys, and so on.

TimurTimur
7,4356 gold badges38 silver badges57 bronze badges

Not the answer you're looking for? Browse other questions tagged pythonwindowscygwin 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: