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.
Related
Visual Studio 2017 now ships with clang, and I was wondering if it is possible to set clang to be the default compiler used when trying to install a python package with Cython dependencies via pip install.
As far as I can tell the issue seems to be that pip doesn't know where to look for clang; it defaults to the path containing the MSVC compiler to compile the .c files specified in the package setup.py. Is there any way I can either 1) set the path to the compiler to be used, or 2) specify that clang should be used explicitly?
I'm working on Windows 10, using the Anaconda distribution and Python 3.6. Any help would be much appreciated!
Do not do it.
It can be done on the command line by setting compiler:
python setup.py build_ext -c <compiler>
python setup.py build_ext --help-compiler to see available options.
However, the same compiler used to build the python distribution must be used for all extensions as the extension modules will be loaded by the interpreter.
If they are built by a different compiler, they cannot be safely loaded by the python interpreter.
In the case of Anaconda, its python distribution is built with MSVC, so the same compiler used by the anaconda environment should be used for extensions. In that case, activating the anaconda environment should suffice, though compiler can be set explicitly as above.
See Windows Compilers python wiki entry.
ImportError: DLL load failed: %1 is not a valid Win32 application
Does anyone know how to fix this? This problem occurs when i am trying to import cv2. My laptop is 64bit and installed 64bit python, i also put the cv2.pyd file in the site-packages folder of Python.
My PYTHONPATH value = C:\Python35;C:\Python35\DLLs;C:\Python35\Lib;C:\Python35\libs;C:\Users\CV\OpenCV\opencv\build\python\2.7\x64;%OPENCV_DIR%\bin;
My OPENCV_DIR value = C:\Users\CV\OpenCV\opencv\build\x64\vc12
I also put reference of my pythonpath and my opencv_dir to the PATH by putting **%PYTHONPATH%;%PYTHONPATH%\Scripts\;%OPENCV_DIR%;**
I also installed opencv_python-3.0.0+contrib-cp35-none-win_amd64 through pip install and command line.
None of this solved my problem.
A bit more elaborate answer for people coming here (like me) in the future:
Uninstall opencv-python, e.g. via pip uninstall opencv-python
Uninstall all visual studio c++ packages
Download the new visual studio from microsoft and install
Download your matching python whl from gohlke and install using e.g. pip install opencv-python-3.2.0+contrib
Now it should work...
(Posting #eryksun comment as a community answer to prevent system from autodeleting question)
Gohlke's cv2.cp35-win_amd64.pyd depends on MSVCP140.dll, the C++
runtime library.
Was that the DLL you need?
The installer for Python
3.5 doesn't include this DLL, so in that case you probably had to install the VC++ 2015 redistributable package.
This can happen if you are using windows 10 N distribution, the N distributions does not come pre installed with windows media feature pack, which is required after OpenCV version 3.4 and onwards.
The preferred solution is to install the feature pack at : https://www.microsoft.com/en-us/software-download/mediafeaturepack
Be careful to choose the version that works with your current version of windows.
If that is not an option, fall back to an earlier version of OpenCV that does not have dll dependencies, you can do that by:pip install opencv-python=3.3.0.9
Since windows rolled out it's N version this problem has been seen at many places, and has many impacts across the windows environment, the fastest way to identify if you have this problem is open youtube in Edge browser, if it says HTML5 media plugin not found, this is the problem.
If the problem still persists, Install dependency walker and find out which modules are causing dependency breaks.
in this case, I just copy file 'python3.dll' from my python3 installation folder to my virtualenv lib folder, and then it works.
I'd like to use aggdraw with Python 2.7. (Is this a dumb idea anyway? I've seen a nice aggdraw example, but I don't want to regress to Python 2.6. Is there an equivalent drawing library working with Python 2.7?) I have Python 2.7.8 64bit installed on a Windows 7 Enterprise SP 1 64bit.
The installer at http://www.effbot.org/downloads#aggdraw complains about Python 2.6 missing, and python setup.py install complains about a missing vcvarsall.bat.
So, following all the related posts here, I installed the MS compiler from http://www.microsoft.com/en-us/download/details.aspx?id=44266. It's visible in the "Programs and Features" list, and I have a vcvarsall.bat in C:\Users\d031475\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0 now.
Still, python setup.py install neither runs in CMD directly, nor in the MS Visual... Compiler for Python 2.7 command prompt which appeared in my Start menu. It still complains about a missing vcvarsall.bat.
EDIT: Even when I append the relevant directory to my path, so that I can run vcvarsall.bat from the command line, python setup.py install still complains it can't find it. How strange is that?
To build with "Microsoft Visual C++ Compiler for Python 2.7" you need to use setuptools >= 6.0 instead of distutils. Try to change the line from distutils.core import setup, Extension in setup.py to from setuptools import setup, Extension.
You'll need to build against the freetype library to enable text rendering.
The aggdraw project appears to be abandoned. The latest version 1.2a3 is from early 2006 and predates Python 2.7, 64 bit, and Pillow. Expect crashes, especially on 64 bit for Windows.
Unofficial Windows binaries for aggdraw are available at http://www.lfd.uci.edu/~gohlke/pythonlibs/#misc.
An alternative to aggdraw is pycairo (Windows binaries).
Do not try to mess around with the Compiler things yourself.
The by far easiest and tested solution is to download the to your environment fitting Windows Binaries for aggdraw from here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
Once you have it go in cmd to your download folder and install with pip (use filename of just downloaded whl script.
pip install aggdraw-1.2a3-cp27-none-win32.whl
DONE!
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 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