Python cross compilation to Windows with Nuitka failing - python

I'm trying to compile a Python 3 file into a Windows executable from inside Ubuntu using Nuitka with the instructions here. When trying to compile, I get the error
Error, no 'Python.h' development headers can be found, dependency not satisfied!
It works when I try to compile for Linux, though
I have the python3-dev package installed and have Python 3 installed in Wine. What can I do to install the Python development headers in Wine?
EDIT: It seems that the header files exist at /home/$USER/.wine/drive_c/Python33/include but Nuitka doesn't see them?

Related

Python py2app and pillow error: Mach-O header is too large

I'm unable to use py2app to build a python application which contains the pillow package. I'm using:
Mac OSX El Capitan (10.11.16)
Python 3.7.3 (Installed via Homebrew)
Pillow 6.0.0
py2app 0.19
macholib 1.11
The script works fine when called from the command line and the py2app bundle works fine if compiled in alias mode python3 setup.py py2app -A
But, when I try to compile a standalone bundle using:
python3 setup.py py2app --packages=PIL
I get the following error message:
ValueError: New Mach-O header is too large to relocate in '/Users/RG/Library/Mobile Documents/com~apple~CloudDocs/iHal/Code/QuotesApp/dist/Quotes.app/Contents/Resources/lib/python3.7/PIL/.dylibs/liblcms2.2.dylib' (new size=1688, max size=1680, delta=48)
I've been searching but have had no luck finding help with this issue, is it possible it's an El Capitan (OSX 10.11.16) issue?
my system specs:
Mac OSX Mojave (10.14.15)
Python 3.7.4 (python.org)
Pillow 6.1.0
py2app 0.19
macholib 1.11
I had the same issues as you. The reason why it fails is that the library is wrong compiled. I figured out two solutions.
On my system the library is located at: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/PIL/.dylibs/
If you do not use color management in your project you can delete the library "liblcms2.2.dylib". Now you can run py2app and it will build.
The second solution is more work and the way I use it in my project.
First, you need Xcode because we have to recompile the "littlecms" library.
Xcode is around 6gb and you get it from the Apple Appstore. On my system have the version 10.2.1.
Download the library littlecms in version 2.2: https://www.littlecms.com/
You will be redirected to SourceForge:
https://sourceforge.net/projects/lcms/files/lcms/2.2/
Download one of these files: lcms2-2.2.zip or lcms2-2.2.tar.gz and extract it on your system.
The library source comes with the Xcode project file and you will find in Projects/mac.
If you are familiar with the terminal you can build it without the Xcode GUI. In this case, go into the extracted folder of littlecms and type following commands.
./configure
make
make check
If the last command(make check) runs fine the library is ready for deployment.
You will find the compiled library in the folder: src/.libs/.
Replace the library which comes with the PIL package with your compiled library.
Finally, run py2app to build your project.
If this is not working you have to tell the linker a flag.
Go to your littlecms source folder and type the commands:
make clean
./configure LDFLAGS="-headerpad_max_install_names"
make
make check
Replace the compiled library with the PIL.
so long,
Phil

Fail to compile a python script with dependencies

I have a tiny (70 lines) python script and I need an executable which includes all the dependencies of the script. It should be usable on windows, where python-magic is only usable in connection with cygwin.
Now I've tried to use Nuitka, which gives me a 6MB executable, however it's not executable on windows, as it states it's not a valid executable, without any further information on why it's not.
Then I've been told to try cx_freeze, which I'm unable to install. Pip states my python version is incompatible. (tried it with pip and pip3 and python is installed..)
How could I get an executable for windows, including all dependencies from my python script written on a Unix system.
Windows system: Windows 8.1 64bit
Unix system: Debian Testing; Python 2.7 and 3.4 installed
I'm using python 2.7 on windows 8.1 and pyinstaller works perfectly fine.
If you want to compile an exe file which can be ported without any DLL files or anything you should use the following pyinstaller command:
python pyinstaller.py --onefile your_script_file.py
Try Pyinstaller, it is very useful to make any executable. And If you need a windows executable you have to compile it on Windows!

Failing to build Slycot on windows 7 using anaconda distro

I'm trying to build slycot, a python wrapper around the fortran library SLICOT.
I'm using the anaconda python distribution Anaconda-2.0.1-Windows-x86_64 on a 64-bit windows 7.
The first naive python setup.py build command resulted in
NotImplementedError("Only MS compiler supported with gfortran on win64")
So far so good. After googling for a while, someone recommended simply commenting out the line in numpy. This seems to work. gfortran is called and all the libraries are compiled, but then it fails at linking with the following message
The command line is too long
It seems that listing all the *.o files generates a huge command string which can not be processed.
Any suggestions?
If you are still having this problem, try upgrading to Anaconda-2.1.0. If that still fails and you are not tied to Python2, then install a Python3 environment using the Anaconda3-2.1.0-Windows-x86_64 distribution. Once I did that and a manual package install (steps below) I didn't get the "command line too long" error. I have Anaconda installed in C:\Anaconda - can't tell if that helped or not.
To manually install a package:
Download the package you need (for me it was numpy).
Extract to a directory (I used c:\temp).
Fix gnu.py in the distutils\fcompiler subdirectory per instructions here.
Exit any apps using python and kill any remaining python.exe processes with task manager; not doing this caused my first compile to fail.
Open an Anaconda Command Prompt (a standard admin cmd.exe window will not work).
If you have multiple environments, activate the correct one.
Change to the directory you extracted your package to.
Type python setup.py install

Python3.3 can't find libpython3.3m.so in linux (pip-3.3)

I'm using ubuntu 12.10 with default python3.2. However I downloaded python 3.3 as its much more polished. Of course, since then I have a nightmare with installing modules for 3.3, as python3 packages from synaptic install to 3.2 dir. So, I installed pip using python 3.3. Now I have pip-3.3 command, great. But, when I tried "sudo pip-3.3 install PySide" I quickly got an error: "error: Failed to locate the Python library /usr/lib/libpython3.3m.so". What's more, when I run "sudo pip install PySide" (command for 2.7), it builded and installed and runs flawlessy. Pyvenv and virtualenv both fail too. But I wan't to do it non-env way,just install pyside to global 3.3 lib dir.
So how can I install that PySide to python 3.3? I just can't get it to work... It looks like I will have to stick with default ubuntu python 3 version (this one runs great, everything works both from pip and synaptic), but I like to use newest python as it gets better and better with every release.
Btw, if that matters I also got following warning before that error:
"package init file 'PySide/init.py' not found (or not a regular file)" and
"package init file 'pysideuic/init.py' not found (or not a regular file)"
Edit: I installed full python3.3 from synaptic, including pythoh3.3-dev, debug, lib etc. Everything.
And that dynamic python 3.3 lib exist in /usr/lib/x86_64-linux-gnu/libpython3.3m.so, maybe just python3.3 package for ubuntu is poor and installs it in wrong direction/doesn't do any symlinks tricks?
Please try this answer installing from source (PySide). Download pyside sources and install from source, follow the instructions on the link.

Pygame installation on Windows - error: Unable to find vcvarsall.bat

I have a Win7 64 bit dev machine. I've downloaded and installed Python 2.6.6 32bit. I've also downloaded pygame 1.9.1 for python 2.6 and tried to install it. I got:
C:\pygame-1.9.1release>setup.py install
....
running build_ext
building 'pygame._numericsurfarray' extension
error: Unable to find vcvarsall.bat
What should I do?
(I don't have any compiler or visual studio or anything installed, if it's relevant)
On PyGame's download page - use the msi file which is a dedicated Windows installation instead of downloading the source and executing:
setup.py install
I had a similar problem with a package (Traits) a couple of weeks ago - for me it was because the package was trying to compile extensions and I didn't have Visual Studio. What worked for me was to install MinGW and direct Python to use it as the compiler in the distutils.cfg config file under \Lib\distutils in your Python installation folder. Looks like this page can automate the whole process for you; if you'd prefer to do it manually here's the contents of my distutils.cfg:
[build]
compiler=mingw32
Rerun setup.py and you should be good to go.

Categories

Resources