Jack Bowyer
Jack Bowyer

Reputation: 11

How do I install python on a windows machine using a cygwin terminal?

I am trying to install python through cygwin on a windows machine in order to make use of a statistical program that can only be implemented using python in a linux environment.

I have run setup-x86_64.exe and installed all python related cygwin packages in an attempt to install python, but when I open a terminal and type python I just get

$ python
-bash: python: command not found

which is the same for all python commands I try so clearly the installation has not occurred. However, I have found a path to Python-2.7.9 which appears to contain the files required to build python from source.

When I run ./configure it is successful, but when I then input make it fails due to:

File "build/temp.cygwin-1.7.35-x86_64-2.7/libffi/fficonfig.py", line 33, in   <module>                                                                               
ffi_sources += ffi_platforms['X86_WIN64']
KeyError: 'X86_WIN64'
Makefile:488: recipe for target 'sharedmods' failed
make: *** [sharedmods] Error 1

Anyone know why make won't work?

The options in ./configure --help are unfamiliar to me, could any of these options allow for successful installation?

Any ideas would be greatly appreciated, thank you.

Upvotes: 0

Views: 2074

Answers (4)

Doug F
Doug F

Reputation: 348

So, this question is 3 years old, but this error still happens with most recent versions of Python 2 (tested with 2.7.13 and 2.7.15)

I was able to get python to build by modifying the following file in the build directory.

--- build/temp.cygwin-2.11.1-x86_64-2.7/libffi/fficonfig.py~    2018-11-03 14:51:53.290000000 -0400
+++ build/temp.cygwin-2.11.1-x86_64-2.7/libffi/fficonfig.py     2018-11-03 14:53:41.793000000 -0400
@@ -9,6 +9,7 @@
     'X86': ['src/x86/ffi.c', 'src/x86/sysv.S', 'src/x86/win32.S'],
     'X86_FREEBSD': ['src/x86/ffi.c', 'src/x86/freebsd.S'],
     'X86_WIN32': ['src/x86/ffi.c', 'src/x86/win32.S'],
+    'X86_WIN64': ['src/x86/ffi.c', 'src/x86/win64.S'],
     'SPARC': ['src/sparc/ffi.c', 'src/sparc/v8.S', 'src/sparc/v9.S'],
     'ALPHA': ['src/alpha/ffi.c', 'src/alpha/osf.S'],
     'IA64': ['src/ia64/ffi.c', 'src/ia64/unix.S'],

The source files, in particular src/x86/win64.S, are present in the source tree. For some reason, ./configure does not seem to be properly adding the option to the dictionary in the fficonfig.py file, which causes the KeyError posted in the question. After making this modification, make and make install completed successfully and I was able to install an alternate version of python in addition to the normal Cygwin package.

I'm not yet sure why this happens, but I thought I would attempt to provide a solution to the question actually asked rather than just telling the asker to install a pre-compiled version using the package manager.

Upvotes: 1

Jack Bowyer
Jack Bowyer

Reputation: 11

Since building Python from source was said to be a bad idea, I assumed my Cygwin was broken. I attempted to uninstall Cygwin following the instructions on the Cygwin website, but I was unable to remove it due to permission difficulties (I use a university-supplied Windows machine). My last resort was to run the Cygwin installation wizard setup-x86_64.exe and uninstall all packages, then run the wizard once more and select the necessary packages again as if starting from new. Miraculously, installing the required packages from scratch solved the problem and I am now running Python through my Cygwin terminal with no errors.

Upvotes: 0

choroba
choroba

Reputation: 241868

Cygwin comes with an installer, called setup.exe or setup-x86_64.exe. Just run it and type python to the search box. Then let it install it for you.

python language interpreter is the basic package you need.

Upvotes: 1

ForceBru
ForceBru

Reputation: 44838

If you want to run Python on Cygwin, you might need to build it from source.

  • download the source
  • unpack it to the directory you could delete later, eg: build
  • run Cygwin, type: cd /path/to/build
  • run ./configure --help and read the help about the options you'll need
  • ./configure #options
  • make

Upvotes: -1

Related Questions