Cygwin Install Python
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
.
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
).
The simplest way to install Python is to install the Python package right at the beginning of the Cygwin installation. Cygwin lets you choose among supported packages such as Ruby, PHP and Python. Once installed, invoke Python in Cygwin by typing 'python -i' without the quotation marks. 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.
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.
SkilldrickSkilldrick3 Answers
AmroAmroThe 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
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):
Python 3 Cygwin
And that seems to work with ipython as well (if installed):
noisygeckonoisygeckoNot 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:
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.
TimurTimurNot the answer you're looking for? Browse other questions tagged pythonwindowscygwin or ask your own question.
I'm trying to install numpy
on Python 2.7
in virtualenv
(on Cygwin).
However, when I try to import numpy
, I get an ImportError
:
Any suggestion how to install numpy on Python 2.7 in virtualenv?
Note:
Cygwin's Python3 version is 3.6, and seems that pypi numpy's is not yet ready for 3.6.
I purchased a Dean Boca 6 string Serial number: E 031962 and I was wonderin. I have a fender six string serial number 6000768 model number f270sce what. Year of my guitar. The 'Vintage Dean Collection' includes guitars manufactured between 1977 and 1987. Look for a distinctive serial number located on the back of the headstock. Dean guitars made in the United States have a seven-digit serial number. The first two numbers indicate the year the guitar was manufactured. Dean guitar serial number. Dec 21, 2009 Problem is, he says it is a Dean Vendetta 3.0, and the only guitar I can find that looks like the one he has, is a cheap Dean Vendetta XM. He has provided the serial number but I cant find anywhere I can look up the serial number to find out any info on it. Every Dean guitar made in United States comes with a seven digit serial number that is printed on the back of the headstock. First two numbers in the sequence will tell you when your guitar was produced, while the following numbers represent the serial number of the instrument itself. Hi all I know Ibanez ones do, but how about with Deans? And if they do identify date of manufacture, how do you work it out form the number?
Edit 1:
In answer to matzeri's comment, I uninstalled numpy
from pip3 and pip2, and installed numpy
for Python 3 and Python 2 from Cygwin's setup.exe.
Following are the errors I get for numpy when I try to import it afterwards:
1 Answer
Install the package python2-numpy
with cygwin setup.You don't need pip to install it.
python2 -c 'import numpy'
works for me.
As the issue seems on lapack_lite
check that you have /usr/lib/lapack/
on your path.
Otherwise the lapack library will not be operative.
matzeri