Προς το περιεχόμενο

Προτεινόμενες αναρτήσεις

Δημοσ.

Έχω πολλές φορές στο παρελθόν ξοδέψει αμέτρητες ώρες για να βρώ πως μπορεί κάποιος να κάνει εγκατάσταση compiled modules (δηλαδή modules που περιέχουν και κώδικα από compiled γλώσσες πχ C/C++) σε Python στα windows. Η διαδικασία μπορεί να γίνει αρκετά πολύπλοκή, όως θα επιβεβαιώσει κάποιος που έχει προσπαθήσει να κάνει compile το numpy στα windows. Έχοντας φάει πολλές ώρες σε forums και αμέτρητα errors, σύνθεσα έναν οδηγό με την ελπίδα να γλιτώσω πολύτιμο χρόνο (και εκνευρισμό :D) σε κάποιον που μπορεί να τον ενδιαφέρει. Ο οδηγός περιλάμβάνει το MinGW το οποίο ήταν σχετικά εύκολο και τους compilers της Microsoft οι οποίοι ήταν απίστευτα επίπονο να εγκατασταθούν ώστε να δουλέυουν σωστά. O οδηγός είναι στα αγγλικά για να μπορούν να τον χρησιμοποιήσουν και άτομα που δεν ξέρουν ελληνικά.

 

 

This is guide to facilitate the installation of MinGW and Microsoft C/C++ Compilers on Windows

MinGW
1. Install your preferred MinGW compiler (suggested: TDM-GCC http://tdm-gcc.tdragon.net/)
2. Ensure that the \bin directory of the installed compiler is in your PATH
3. a. Edit your cygwinccompiler.py file located in <PythonDir>\Lib\distutils\ (supposedly this is fixed in Python 2.7.6 & Python     3.3.3 and not necessary)
   b. Remove any "-mno-cygwin" instances in the file
4. a. Create a distutils.cfg file in <PythonDir>\Lib\distutils\
    b. In this file add the following:
    [build]
    compiler=mingw32
    #compiler=msvc
    # The # is used to comment out a line, use this if you want to switch from the MinGW to the Microsoft C/C++ compiler
 
 Microsoft C/C++ Compilers
1. You need the same compiler that was used to compile the specific version of CPython on Windows. To use the Microsoft C/C++ compilers you need to install:
    a. For Python 2.7: Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1 (Windows SDK v7.0) (http://www.microsoft.com/en-us/download/details.aspx?id=3138)
    b. For Python 3.3 - 3.4: Microsoft Windows SDK for Windows 7 and .NET Framework 4 (Windows SDK v7.1) (http://www.microsoft.com/en-us/download/details.aspx?id=8279)
2. For Python 3.3: Change line 648 in Python33\Lib\distutils\msvc9compiler.py to "mfinfo = None"
3. Run the corresponding SDK Prompt that automatically sets the environment for the correct compiler
   a. Python 2.7 and Windows SDK 7.0. Run the "CMD Shell" shortcut or from any command prompt: C:\Windows\System32\cmd.exe /E:ON /V:ON /T:0E /K "C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\SetEnv.cmd"
   b. Python 3.3 and Windows SDK 7.1. Run the "Windows SDK 7.1 Command Prompt" shortcut or from any command prompt: C:\Windows\System32\cmd.exe /E:ON /V:ON /T:0E /K "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd"
4. On the commpand prompt, run the following commands:
   a. "setenv /x86 /release" or "setenv /x64 /release" for 32/64 bit versions of Python respectively
   b. set DISTUTILS_USE_SDK=1
   c. set MSSdk=1
   
You can get compiled versions of setuptools and pip to facilitate the installation of Python libraries from Christoph Gohlke (http://www.lfd.uci.edu/~gohlke/pythonlibs/). There you can find a collection of already compiled binaries for Windows for many Python libraries.
You can now compile yourself,install and enjoy your favorite Python compiled libraries! :D

  • Like 3

Δημιουργήστε ένα λογαριασμό ή συνδεθείτε για να σχολιάσετε

Πρέπει να είστε μέλος για να αφήσετε σχόλιο

Δημιουργία λογαριασμού

Εγγραφείτε με νέο λογαριασμό στην κοινότητα μας. Είναι πανεύκολο!

Δημιουργία νέου λογαριασμού

Σύνδεση

Έχετε ήδη λογαριασμό; Συνδεθείτε εδώ.

Συνδεθείτε τώρα
  • Δημιουργία νέου...