I get a numpy.core.multiarray failed to import error whenever I try to build an exe file using cx_Freeze.
My system uses the following versions:
python 3.6.0
opencv 3.3.0
numpy 1.13.1
cx_Freeze 5.0
The code is:
import cv2
i=333
print(i)
It runs fine (i.e. builds a good exe file) only if I remove the import cv2 line.
Is there any incompatibility between the four modules I listed?
I managed to make this work only after I uninstalled cx_Freeze and installed Pyinstaller instead. It works like a charm.
If this can help you, I managed to make a working example under Linux using SimpleCV with the following configuration:
python 2.7.12
SimpleCV 1.3
numpy 1.11.0
cx_Freeze 5.1.1
The example code cv2_example.py is:
import encodings
import cv2
print cv2.__version__
i = 333
print i
The setup script setup.py is:
from cx_Freeze import setup, Executable
build_exe_options = {'packages': ['numpy']}
exe = Executable(script='cv2_example.py', base=None)
setup(name='cv2_example',
version='1.0',
executables=[exe],
options={'build_exe': build_exe_options})
I guess this example could work also for your configuration with python 3.6.0 and numpy 1.11.0 provided you upgrade cx_Freeze to version 5.1.1.
Related
I'm using Python 3.5 and would like to export my python code for me to send to others who do not have Python installed. Thing is Pyinstaller doesn't work as I get this error:
CX_Freeze also doesn't work for me either as Tkinter still presents a problem, on running python setup.py build I get:
KeyError: 'TCL_LIBRARY'
I'm getting sick of this to be frank so any help would be appreciated. Here's my imports in my code if it helps
import pdb
from tkinter import *
from tkinter import filedialog
import tkinter.messagebox
from datetime import datetime, date, timedelta
import pandas as pd
import numpy as np
from xlsxwriter.utility import xl_rowcol_to_cell
If you are using an older version of cx_Freeze(<5.0), it doesn't have Python35 support. The latest development version has Python35 support. You can install it by
pip install cx-Freeze-win
But you need to have VC++ run-time installed on your system to run this successfully.
Also I've found this GitHub-repo with pre-built binary packages of cx_Freeze 5 for windows platform.
pip install wheel
https://raw.githubusercontent.com/sekrause/cx_Freeze-Wheels/master/cx_Freeze-5.0-cp35-cp35m-win_amd64.whl
Well I managed to get it working by downloading Pyinstaller from the website and running the commands in the new folder. I followed the steps in this answer here.
I am installed some modules for python, numpy, biopython, mx.. on my mac (10.10.5). I started the Terminal and tried to import them and it works.
After that I installed Spyder, when I try to import bumpy in Spyder it works but biopython (from Bio import *) does not work -> (ImportError: No module named Bio).
also import mx does not works.
If I start Python in the Terminal the import still works.
I'm trying to use pyinstaller, on OSX Mavericks, with one a Python script. Pyinstaller compiles and packs along until it finds an error with the Pillow library.
ImportError: dlopen(/Users/Rodolphe/.python-eggs/Pillow-2.2.1-py2.7-macosx-10.9-intel.egg tmp/PIL/_imaging.so, 2): Library not loaded: /usr/local/lib/libjpeg.8.dylib
Referenced from: /Users/Rodolphe/.python-eggs/Pillow-2.2.1-py2.7-macosx-10.9-intel.egg-tmp/PIL/_imaging.so
Reason: Incompatible library version: _imaging.so requires version 13.0.0 or later, but libjpeg.8.dylib provides version 9.0.0
It looks like Pyinstaller and Pillow are not getting along (it seems to be a known fact: http://www.pyinstaller.org/ticket/745 ). Is there a way around it? Should I try uninstalling Pillow and installing Pil instead (I chose Pillow out of discouragement from Pil's reluctancy to install on Mavericks, to begin with)? Or maybe update libjpeg.8.dylib to version 13.0.0 as it seems to be the problem?
[EDIT]
I have updated libjepeg thanks to the advice from #mimi.vx I now have another error at the very end of the process:
IOError: [Errno 20] Not a directory: '/Library/Python/2.7/site-packages/Pillow-2.2.1-py2.7-macosx-10.9-intel.egg/PIL/_imaging.so'
I tried reinstalling Pillow so Pyinstaller would maybe get the directory, but no luck yet...
[RE-EDIT]
Using py2app instead of pyinstaller worked for me!
Yes, first try update libjpeg
Good help for OS X can be found in this blog http://brantsteen.com/blog/python-27-libjpeg-pil-on-osx/
libjpg latest source is here www.ijg.org
And Pillow recommended install on OS X is described in pypi.python.org/pypi/Pillow/2.2.1
It is over homebrew $ brew install libtiff libjpeg webp littlecms
Pyinstaller was behaving strangely while importing PIL. I tried using py2app ( http://pythonhosted.org/py2app/ ) instead, and it worked like a charm. No lib ray import trouble or anything. I'd recommend it.
I'm more or less new to python
I'm trying to install pyside and QT on a mac but I can't figure out how to install them.
I downloaded install files "pyside-1.1.0-qt47-py27apple.pkg" from http://qt-project.org/wiki/PySide_Binaries_MacOSX and "Qt libraries 4.8.5 for Mac" from http://qt-project.org/downloads.
double click on both files and installed. but it looks like it didn't work.
I can import PySide but nothing else.
in Python Idle when I type
import PySide
print PySide.__version__
1.1.0
then if I do:
import PySide.QtCore
I get this error.
Traceback (most recent call last): File "", line 1, in
import PySide.QtCore ImportError: dlopen(/Library/Python/2.7/site-packages/PySide/QtCore.so, 2): Library
not loaded: QtCore.framework/Versions/4/QtCore Referenced from:
/Library/Python/2.7/site-packages/PySide/QtCore.so Reason: no
suitable image found. Did find:
/Library/Frameworks/QtCore.framework/Versions/4/QtCore: mach-o, but
wrong architecture
I have python 2.7 and PyCharm. I also have installed setuptools and pip.
I looked around online and I see a lot of people had the same problem. but I couldn't find any answer that worked for me.
I hope anyone can help me out with this.
This worked for me:
sudo pyside_postinstall.py -install
Note: I'm using PySide 1.2.2, Qt 4.8.6, Mac OS X 10.9.3.
Edit: There is no more need to call the post-install script on Linux and MacOS systems since version 1.2.3 (2015-10-12).
I made a python package using distutils that in its setup.py file, has:
setup(name = "foo",
version = "0.2.1",
...)
when I do:
import pkg_resources
pkg_resources.get_distribution("foo").version
I get 0.2 and not 0.2.1. Why is that? how can i get the full version? thank you.
pkg_resources looks for installed distributions in your Python installation. Have you re-ran python setup.py install or python setup.py develop after you’ve changed the version?
Try inspected the object returned by get_distribution for an attribute showing where the location is located on the file system; maybe foo is not installed where you think it is, and an older version is found instead.
It looks like a bug to me. If the package was installed with distutils instead of setuptools, then pkg_resources.get_distribution() returns the oldest version installed.
The best way to fix it is to replace:
from distutils.core import setup
with:
from setuptools import setup