Is it possible to build Python interpreter from source with Mingw and gcc on Windows 7?
And I would like to biuld a 64bit version.
If a 64bit Python (gcc Mingw) version is available for download please let me know, I would use that also.
At the end I still would like to compile it with gcc and mingw.
First off, you do not need to build Python with MinGW-w64 to link to it and embed a interpreter. Just extract the msi installer, and use the prebuilt DLL. Note you'll have to be careful not to mix msvcr[t|90].dll objects, but I've never seen that be a real issue personally.
MinGW-w64 gcc/ld should be able to link to DLL's directly, otherwise you'll have to use gendef to create a .def file and dlltool to create an import library.
Secondly, there's a patchset to build Python with MinGW, but I'm not sure about its 64-bit compatibility.
You may try this repository:
hg clone https://bitbucket.org/puqing/python-mingw
It is a copy of the official repository but contains some modification to make it compile with mingw. Enter PC/MinGW directory:
cd PC/MinGW && make
Not sure if it compiles in win64, but with win32 and msys it should work.
Related
I'm trying to get a blender addon, animation nodes, working on a x86 computer. To my lack of luck, there's only 64 bit builds avalible.
In the past, I've found a previously compiled version of the addon - unluckily, this was for blender 2.78, and not 2.8.
https://blender.community/5d28871ad3ac8b41e5d7215c/download/5d288762d3ac8b41e5d7215e is the code.
Upon importing the addon into 2.8, I get the standard Could not compile wall of text. When importing the older addon, it comes up as upgrade to 2.8x required, as usual.
If the supplied addon distributions don't work for you, then you need to compile your own version.
You will need cython and a C/C++ compiler to compile the addon. Your python version should match the blender install which is v3.7 for blender 2.80
Download the git repo and checkout the blender2.8 branch
Create conf.json at the top of the repo and set the Copy Target to the location of your blender addons directory
Run python setup.py build --copy to build and install animation nodes
Alternatively use python setup.py build --export to build it into a zip file for you to install manually
I've downloaded python libraries (tar.gz) from external links. How to use these libraries, I mean in which directory under the python should I unzip such libraries.
How to use downloaded libraries with python when we are using:
windows 7
Ubuntu
Also how to install these libraries without using pip in Linux? Do we have to set path in windows7 to use the libraries?
Guys better to post comments then to give negative points. With your suggestion I can modify my post. I dont think you to be smart guy by rating negative points in any comments.
For Linux based systems (e.g., Ubuntu):
$ tar xzf package.tar.gz
$ cd package
$ python setup.py install
Also, look input pip https://pypi.python.org/pypi/pip
On Windows and Linux, all you need to do is unzip the archive somewhere, cd into and run the following command as administrator (usually by running cmd.exe as Administrator on Windows or by using sudo on Linux):
python setup.py install
If the package does not have a setup.py, it can get tricky. Most of the time the package just needs to be copied into your Python's site-packages folder.
You will find some packages that need to be built. On Linux, you can usually do this pretty easily. On Windows, you will need the appropriate compiler, usually a free version of Visual Studio will do, although you have to make sure you get the correct version of Visual Studio. I've heard reports that you can also use MingW.
I have tried everything given and the tutorials all point in the same direction about using mingw as a compiler in python instead of visual c++.
I do have visual c++ and mingw both. Problem started coming when I wanted to install using pip. It always gave Unable to find vcvarsall.bat
So as per suggestions I created a file distutils.cfg under the following path c:/python27/Lib/distutils/ and added the following two lines:
[build]
compiler=mingw32
However, this file has no effect whatsoever. The same error still exists while using pip. I am trying to install numpy by the way currently although the error came earlier also.
Cost me several hours to figure this out but now works like a charm.
I am on Windows 64bit and using a scientific Python distribution Enthought Canopy.
Ensure you have installed MinGW and the Compilers you need (C, C++, Fortran..)
Add C:\MingW\bin to your PATH in Environment variables
In C:\Users\MyName\AppData\Local\Enthought\Canopy32\App\appdata\canopy-1.6.2.3262.win-x86\Lib\distutils, create with notepad++ or similiar a new file distutils.cfg
Write and save:
[build]
compiler = mingw32
[build_ext]
compiler = mingw32
Difficult Solution (Building using the C/C++ compiler)
Are you on Windows 32bit or 64bit? Are you specifying the build when you're compiling? For example, do the following in your shell or bash:
python setup.py build --compiler==mingw32
python setup.py install
Easier Solution (Use pre-built binaries)
If you don't have to compile the program, you can use the unofficial Windows binaries from here
Do you happen to use virtualenv as well?
Anyway, use Microsoft Visual C++ Compiler for Python 2.7
and a newer setuptools. The one bundled with virtualenv (3.6) does not support this compiler.
pip install "setuptools>=6.0"
Credits: http://blog.ionelmc.ro/2014/12/21/compiling-python-extensions-on-windows/
I am having a very difficult time installing pymc on windows. I do
easy_install pymc
But it gives the error
error: Setup script exited with error: extension 'pymc.flib' has Fortran sources but no Fortran compiler found
However, I installed the gFortran compiler within MinGW. Do I have to change the environment variables or something?
thanks,
First, ensure that you do in fact have the Fortran compiler installed with MinGW. If you open up MinGW Installation Manager (in C:\MinGW\libexec\mingw-get\guimain.exe) you will see a list of packages. If mingw32-gcc-fortran is unchecked, check it and click Installation > Apply Changes.
Secondly, check your PATH to make sure that C:\MinGW\bin is there and that there are not other versions of MinGW in the path (like a 64 bit version).
Lastly, if you are using 32-bit Python then your MinGW should be 32-bit, if 64-bit Python then use 64-bit MinGW.
That sounds like the issue. You should probably add C:\MinGW\bin to your PATH.
I installed distribute and pip using the links I have just given. I also installed the Microsoft Visual C++ 2008 redistributable package. However when I try to use pip.exe I get
error: Unable to find vcvarsall.bat
How can I fix this?
Installing the Microsoft Visual C++ 2008 Redistributable Package is not sufficient to compile packages. You need to install a compiler, not just the support files.
There are three ways to do this:
Install Visual C++.
Use mingw's port of gcc instead of Visual C++.
Use cygwin's port of gcc instead of either, and a cygwin build on Python instead of the native one.
If you want to go with option 1, you need to install Visual C++ itself. The free version should work just as well as the paid version, as long as you're not going to build binary packages to redistribute to others. Unfortunately, I'm not sure where to find the 2008 version anymore. As of May 2013, the download page only has 2010 and 2012.
When you install this, it will create a batch file called vcvarsall.bat (not vcvarshall.bat!), and give you the option of putting that batch file in your PATH. Running that batch file sets up a DOS prompt for building with that version of Visual C++. (This is handy if you have multiple versions of Visual C++, or other compilers, around.) If you skip that option, you will have to do it manually.
This question shows how to use a newer Visual Studio with older Python, and also shows how to point distutils at a vcvarsall.bat that's not on your PATH, and has links to a whole lot of other relevant questions and blog posts.
Many people find option 2 simpler. Install mingw, modify your PATH in the environment to include C:\MinGW\bin (or wherever you choose to install it), and pass -c mingw32 whenever you run a setup.py script.
The problem is that it's not as clearly documented how to tell easy_install and pip to use mingw instead of VC++. To do that, you need to find or create a distutils.cfg file, find or create a [build] section within it, and add compiler=mingw32. Not too hard. This blog post looks like it explains things pretty well, or see this answer.
Option 3 is by far the simplest. Install cygwin, tell it to install the Python and gcc packages, and you're done.
The problem is that you don't have native Windows Python, you have a Unix Python running in a fake Unix environment on top of Windows. If you like Cygwin, you'll love this; otherwise, you won't.
You'll receive such error only for packages (or one of package's dependencies) that has CPython extensions. Pip internally:
downloads the source
runs distutils python setup install
install prepares setup files and tries to build CPython extensions in windows environment
windows environment calls MS Visual Studio vcvarsall.bat script which setups DOS environment variables to enable MS Visual Studio's C compiler in the shell
if vcvarsall.bat is not found - you'll get this message
Usual solution
For python libraries which have CPython extensions that are portable on windows, it is usual to have windows binary package, which are downloadable from pypi or library web site.
In such cases it is more suitable (and painless) to install library by downloading and running windows binary package.
There is a feature request for pip to Add support for installation of binary distutils packages on Windows.
New way to do it - wheels
Thanks to comment from #warren-p: That feature request has been superseeded by Wheels support in PIP.
Official description: A wheel is a ZIP-format archive with a specially formatted filename and the .whl extension.
As I have understood, if there is windows binary package with extension .whl then start by installing wheel first:
# Make sure you have the latest pip that supports wheel
pip install --upgrade pip
pip install wheel
and then install .whl like this:
pip install full-path-or-url-to-your-library.whl
References:
pythonwheels.com
https://pypi.python.org/pypi/wheel
http://wheel.readthedocs.org/en/latest/
You can download Visual Studio 2008 Express SP1 from
http://visual-studio-2008.en.malavida.com/
You can deselect the two add to browser options it offers.
I found these links on microsoft.com that still work to Install Visual C++.
http://download.microsoft.com/download/8/B/5/8B5804AD-4990-40D0-A6AA-CE894CBBB3DC/VS2008ExpressENUX1397868.iso
2008 SP1 here
http://download.microsoft.com/download/E/8/E/E8EEB394-7F42-4963-A2D8-29559B738298/VS2008ExpressWithSP1ENUX1504728.iso