Issues compiling GTK software in MSYS2/MinGW with PyInstaller - python

I had a year old version of MSYS2/MinGW that was using PyInstaller with Python3.7 to compile a C GTK application in Windows (python was needed for a plotting script) and everything worked fine until pacman refused to update any packages since I kept getting the error:
error: hook /usr/share/libalpm/hooks/mingw-w64-x84_64-gtk-query-immodules-3.0.hook line 2: invalid value Path
error: hook /usr/share/libalpm/hooks/mingw-w64-x84_64-gtk-update-icon-cache.hook line 2: invalid value Path
Errors occurred, no packages were upgraded.
I looked those up and the general response for it is: "The issue is usually provoked when you don't maintain your system at regular intervals - and I am not thinking yearly - because such neglect will often result in similar problems. The issue stems from a change in pacman code..."
So I decided to start from a fresh MSYS2 install and used the following lines from both an MSYS2 shell and a MinGW-x64 shell, and each of them fails at a different point:
pacman -Syu
pacman -Su
pacman -S nano
pacman -S mingw-w64-i686-gtk3
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-gtk3 mingw-w64-x86_64-python3 mingw-w64-x86_64-python3-gobject
pacman -S --needed base-devel mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain git subversion mercurial mingw-w64-i686-cmake mingw-w64-x86_64-cmake
pacman -S python3-pip
pacman -S mingw-w64-x86_64-python3-pip
pacman -S msys2-devel
pacman -S mingw-w64-x86_64-glade
pacman -S mingw-w64-x86_64-gobject-introspection
pip install pyinstaller
In the case of the MSYS2 shell, the pip install pyinstaller fails with:
# pip install pyinstaller
Collecting pyinstaller
Using cached PyInstaller-3.6.tar.gz (3.5 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3.exe /usr/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpd9hk1ekp
cwd: /tmp/pip-install-ouq11vnr/pyinstaller
Complete output (1 lines):
Your platform is not yet supported. Please define constant PYDYLIB_NAMES for your platform.
An internet search shows this issue coming up on the github page for PyInstaller and a post here, neither of which were remotely enlightening:
https://github.com/pyinstaller/pyinstaller/issues/4542
How to fix: PyInstaller in MSYS2 MinGW 'Your platform is not yet supported'
In the case of a MinGW shell, I can install everything fine, but I cannot compile the C code because I get the error:
fatal error: sys/wait.h: No such file or directory
7 | #include <sys/wait.h>
| ^~~~~~~~~~~~
compilation terminated.
Which means that MinGW doesn't know where to look for this file. It is located in:
msys64/usr/include/sys
but I suppose that only works for an MSYS2 shell? And yet my year old MinGW shell will compile the C code without this error, but despite every effort (following the bash history for package installation for the working version, manually copying over package folders, on and on) I continue to come up against this error. Just copying the folder above into the MinGW include folder results in further issues and is clearly sloppy. I want a repeatable way to get this to work, and I have repeated the process outlined above on several computers and have got the exact same result every time - so I expect anyone starting with a fresh MSYS2 install will run up against the same problems. Any help in getting this to run would be very much appreciated as I am getting frustrated with all of the dead ends.

I was finally able to get this figured out. The first thing to know is that the initial compiling must be done in the MSYS2 shell. Once you successfully compile it in the MSYS2 shell, you can then compile in the MINGW shell without issue. I am not sure why that is so, but I anticipated it would be the case.
I solved the PyInstaller issue by downloading Python 3.7 from http://repo.msys2.org/ and installing it using:
pacman -U python-3.7.2-1-x86_64.pkg.tar
I also needed Python 3.7 installed in Windows, and the path edited in my .bashrc file:
export PYTHON_HOME=C:\\Users\\Leigh\\AppData\\Local\\Programs\\Python\\Python37
export PATH="$PYTHON_HOME:$PYTHON_HOME\\Scripts:$PATH"
I am not sure if PyInstaller is compatible with Python 3.8 yet. I posted an issue to their GitHub page, and it is here for reference in case it is resolved:
https://github.com/pyinstaller/pyinstaller/issues/4996
PyInstaller then worked, but I was met with another issue that I posted to Stack Overflow, but figured out as well. That is here:
MSYS2 gcc fatal error in cc1.exe: cygheap base mismatch detected
After that issue was resolved I could compile my program in MSYS2. Switching over to a MINGW shell, I found that it now compiled there as well.

sys/wait.h isn't there in MinGW, but you can use the one from: https://github.com/win32ports/sys_wait_h

Related

How to fix : pyconfig.h not found with Anaconda

I am setting up boost-python for the python bindings of a library. Previously, boost was installed but linked against python2.7. After some tribulations, everything from the previous boost install is gone and I am trying to install a fresh boost.
I am using Linux Mint for the record, and Anaconda with python 3.6.8.
It works correctly in the CLI : python --version gives 3.6.8
I then begin to follow the instructions for building boost : https://www.boost.org/users/history/version_1_69_0.html
What I got from other threads is to do this :
sudo apt-get install python3-dev
I am not sure I am supposed to since I have anaconda3 but anyway, I did it.
./bootstrap.sh
here the file project-config.jam is created and the line about python says :
using python : 3.6 : /home/myUser/anaconda3 ;
I then proceed to build with b2 :
sudo ./b2 --with-python -j8 install
the installation fails with literally a wall of text full of these :
./boost/python/detail/wrap_python.hpp:50:11: fatal error:
pyconfig.h: No such file or directory
# include <pyconfig.h>
^~~~~~~~~~~~
compilation terminated.
When I search inside ~/anaconda3/include/python3.6m the file pyconfig.h sits there as expected
Is there additional information I should give to b2 or bootstrap ?
I face the same problem for installing boost 1.70 and Anaconda3 with python Anaconda with python 3.7.1. I found an answer based on this question.
Ubuntu - Linking boost.python - Fatal error: pyconfig cannot be found
By the way to solve this problem first you should find the "pyconfig.h" file in the installation directory of Anaconda. For me it's in "~/anaconda3/include/python3.7m". Then export this address or just add this address to the .bashrc file.
export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:path/to/your/Anaconda3/include/python3.7m"
Put the address to Anaconda in your pc instead of path/to/your/Anaconda3. Remember to restart the terminal after this. Then again just run "./b2" in the boost folder. It should compile the rest.

pystan: CompileError: command 'gcc' failed with exit status 1 (Windows)

Before I get to far into this, I should note that I have seen a very similar question, but the solution presented did not work for me. Perhaps one reason why is because that was Linux build and my current difficulty is on a Windows 7 machine. I use Cygwin to get access to the gcc (5.2.0) compiler suite.
In any event, I have been attempting to try out Stan via PyStan. I am working with an Anaconda (2.4.1 64-bit) distribution which I just updated today (Python 2.7.11). I initially tried to install PyStan via pip, but the install keeps failing due to what looks like the following error:
Cannot build msvcr library: "msvcr90d.dll" not found
Consequently, I used conda instead, which seemed to install just fine. (I should note that the conda install pushed my numpy back to an earlier version, which created conflicts with the pandas upon import. I just updated anaconda to deal with these broken dependencies.) I was also able to import PyStan without any problems. However, when I actually tried to fit a model (inside of a Jupyter Notebook), the process failed with the exception in the title.
The first thing I did was confirm that gcc was where in the referenced location (not shown in the title). Indeed it was, and it seemed to working just fine. I then tried to run the model as a script from the command line (still using Python), and it failed with the same error. When I recreated the model via the REPL, it pointed to a different location that had a .bat file referencing the (verified) compiler, and that failed as well.
I am pretty sure this is because I have Visual Studio 2012, instead of Visual Studio 2008. While it is possible for me to run parallel installations, if this code is going to be useful for others in the future, these are not reasonable hoops to jump through to make it happen. I was hoping that someone else might have a better explanation. Any info would be greatly appreciated.
Beneficial from the post at https://github.com/stan-dev/pystan/issues/306
I have met various error message, but finally, I install PyStan successfully.
My machine is also on Windows 7, x64 with Anaconda3 installed.Here are the procedures to install PyStan from the sourced codes.
Install Visual Studio 2017 & Visual Studio C++ Build Tool 2015 at http://landinghub.visualstudio.com/visual-cpp-build-tools
Update Conda
conda update conda
conda update --all
check the dependencies
pip install setuptool
conda install numpy cython matplotlib scipy pandas
Install gcc compiler components
conda install libpython
conda install -c msys2 m2w64-toolchain=5.3.0
created distutils.cfg file inside Anaconda3\Lib\distutils folder with the following:
[build]
compiler = mingw32
Download Git at https://git-scm.com/downloads
git clone --recursive https://github.com/stan-dev/pystan.git
Compile from the source code
python setup.py build --compiler=mingw32
python setup.py install
P.S. The solution for the issue: Cannot build msvcr library: "vcruntime140d.dll" not found.
Copy vcruntime140d.dll from C:\Windows\System32 to any folder, which is reachable in the path in the advanced system settings/environment variables/ system variables.

Problems with Installing Python Packages

I've seen some past threads that discuss similar problems, but none seem to be having exactly the problem that I am having. I was having problems with installing packages with Python, even though I'd managed to install them before. When I attempted to run gcc, it seemed to not be installed, so I uninstalled Xcode completely and just installed the command line tools (I really only use the command line tools, and could use the extra disk space).
Though the installer said that the installation was successful, gcc results in the following error:
xcrun: Error: could not stat active Xcode path '/Applications/Xcode.app/Contents/Developer'. (No such file or directory)
I have tried to redirect the path by using the following command:
export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"
It doesn't seem to work, though.
I've also tried using the following command:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
but it returns the following error: xcode-select: Error: Path "/Applications/Xcode.app/Contents/Developer" is not a directory.
Which makes sense I think -- after all, I did uninstall Xcode, so I suppose I should point it to the Command Line tools directory? I'm not sure how to do this, though.
I'm using Mac OS X 10.8.5, by the way.

Installing (build) matplotlib in mac osx lion

I installed pynum and scipy (on osx Lion with python 2.7), but when I tried to build matplotlib
git clone https://github.com/matplotlib/matplotlib.git
cd matplotlib
python setup.py build
python setup.py install
I've got these errors:
/System/Library/Frameworks/ApplicationServices.framework/Frameworks/ATS.framework/Headers/ATSTypes.h:242: error: declaration for parameter ‘FMFontDirectoryFilter’ but no such parameter
src/_macosx.m:5912: error: expected ‘{’ at end of input
lipo: can't open input file: /var/folders/qw/pr2f7vq91b3c3ngkxrrqplm8zkv09r/T//ccAgEklo.out (No such file or directory)
error: command 'llvm-gcc-4.2' failed with exit status 1
Could somebody please tell me what is the problem?
P.S.
At first I tried to install it in this way:
pip install -e git+https://github.com/matplotlib/matplotlib#egg=matplotlib-dev
but it does not worked for me
I always find this process more painful than it should be, but I've done it a few times now and I believe that these steps should get you set up:
Get Xcode 4.3.2, it's required for some of the later steps.
Download the latest version of python for OSX from python.org
Grab the Scipy superpack.
Uninstall any previous versions of numpy/matplotlib/scipy that you currently have. That includes doing cd /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ and moving any numpy/matplotlib/scipy directories or eggs into a temp directory.
cd ~/Downloads(or wherever you downloaded the superpack script to) and run sh install_superpack.sh. Answer no to the question are you installing from a repository cloned to this machine or you'll be confused about why the script keeps failing.
That should be it! You should now be able to boot up the python console and import numpy, scipy, matplotlib.

Why am I getting the error: command 'llvm-gcc-4.2' failed with exit status 1

I am setting up os X 10.7.
I am using the default install of Python:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/
I use a Python based package manager called easy_install.
Easy_install seems to not be able to find the compiler.
EDIT: When I tried to install MySQL-python I got this error:
$ sudo easy_install MySQL-python
Password:
Searching for MySQL-python
Reading http://pypi.python.org/simple/MySQL-python/
Reading http://sourceforge.net/projects/mysql-python/
Reading http://sourceforge.net/projects/mysql-python
Best match: MySQL-python 1.2.3
Downloading http://download.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.3.tar.gz
Processing MySQL-python-1.2.3.tar.gz
Running MySQL-python-1.2.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-P9H9WX/MySQL-python-1.2.3/egg-dist-tmp-rRTfZL
warning: no files found matching 'MANIFEST'
warning: no files found matching 'ChangeLog'
warning: no files found matching 'GPL'
unable to execute llvm-gcc-4.2: No such file or directory
error: Setup script exited with error: command 'llvm-gcc-4.2' failed with exit status 1
error: Setup script exited with error: command 'llvm-gcc-4.2' failed with exit status 1
Xcode 4.1 used GCC, but with Xcode 4.2 that seems to have changed.
What compiler does Apple want us to use?
How do I setup the configuration so I can compile OSS?
I had the exact same problem when I upgraded from OSX 10.6 to 10.7. If you upgrade to 10.7 from 10.6, your version of Python may go from 2.6 to 2.7 and a result you may need to re-install most of your python packages.
Here's what worked for me:
Install the latest version of XCode from the App Store
Inside XCode, go to Preferences -> Downloads -> Components
download the Command Line Tools
That's all you need to do. Try to install again in a new shell. The command line tool installation will put llvm-gcc-4.2 into /usr/bin which should be in your default path. The installation also takes care of library paths and stuff that you don't really want to know about unless something breaks.
10.9 edit
If you're running 10.9 or higher, I think you might be able to run this from the command line instead to install the command line tools:
xcode-select --install
I haven't verified that this is an actual fix to the problem.
Alternative to installing Xcode, install GCC and related tools via:
https://github.com/kennethreitz/osx-gcc-installer
Sounds to me you ran into this issue. The thread shows a variety of solutions.
Hope that helps.
The fix is quite simple. Check out the following blogpost.
http://waqasshabbir.tumblr.com/post/19073648382/llvm-gcc-4-2-exe-error-on-mac-osx-lion-when-building
Using OS X 10.7.5 (Lion)
I tried the XCode solution, but my gevent pip installation still wasn't successful. Then, I tried building libevent from source but still no success with gevent installation. However, after I did
brew install libevent
I was able to successfully install gevent with
sudo pip install gevent
(Note: greenlet is also a dependency for gevent, so you may try installing it with pip as well. It was already installed on my machine.)
All of the suggestions here (Xcode command line options, and Kenneth Reitz' stuff) didn't work for me (I am on Mac OS X 10.7.5, Xcode 4.6.3).
What helped in the end was altering the cflags options in the mysql_config file (There were errors about 'unreconized command line options' while trying to 'sudo pip install MySQL-python').
See this post: cc1: error: unrecognized command line option "-Wno-null-conversion" within installing python-mysql on mac 10.7.5

Categories