Python 2.7 script compiling to .exe that uses many packages, including Matplotlib and PyQt4 - python-2.7

I'm trying to compile a Python 2.7 script that imports the following packages:
import easygui as EG
import numpy as np
import pandas
from skimage import data
from skimage import measure
import cv2
import matplotlib.pyplot as plt
from matplotlib.widgets import Button
import ntpath
import os
import time
# Packages for progress bar
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtCore import pyqtSlot,SIGNAL,SLOT
easygui
numpy
pandas
skimage
opencv (cv2)
matplotlib
numpy
ntpath
os
time
sys
PyQt4.QtGui
PyQt4.QtCore
All of my sub-functions are in the one "GUI.py" script, and runs perfectly when I use the normal IDE, but I can't seem to get it to compile properly.
I have tried to use cx_freeze as described here, and pyInstaller through what was described here. Both did compile and a "GUI.exe" file was made, but it did not work when I tried to run it.
If anyone has any suggestions, I would greatly appreciate it.
I'm using Python 2.7 Win 64 and I use Anaconda 2.

Related

Caffe2 Import Throwing Error in Python free() invalid size

I'm trying to import the following modules for a Caffe2 tutorial.
Tutorial here: https://github.com/caffe2/caffe2/blob/master/caffe2/python/tutorials/Loading_Pretrained_Models.ipynb
Modules here:
%matplotlib inline
from caffe2.proto import caffe2_pb2
import numpy as np
import skimage.io
import skimage.transform
from matplotlib import pyplot
import os
from caffe2.python import core, workspace, models
import urllib2
print("Required modules imported.")
But it's throwing the following at import.
"* Error in `python': free(): invalid size: 0x0000000000de4e80 *
Aborted (core dumped).
I deleted each line one by one and found the problem line being:
from caffe2.python import core, workspace, models
If I remove this, it will import without issue.
Now, if I import this via the python IDE it works.
Any help would be appreciated!
Thanks

I can't import random

I'm new to Python. When I imported random and easygui, there were these error codes:
No module named random
No module named easygui
But I have easygui installed on my computer.
Python
import random,easygui
secret=random.randint

can't import package pandas, statsmodels and matplotlib on Jupyter for anaconda

I failed to import package pandas statsmodels and matplotlib in Jupyter in Anaconda 2,
import pandas
import statsmodels
import matplotlib as mpl
for example the error information for import pandas like this
--------------------------------------------------------------------------- ImportError Traceback (most recent call
last) in ()
----> 1 import pandas
/Applications/anaconda/lib/python2.7/site-packages/pandas/init.py
in ()
29 "pandas from the source directory, you may need to run "
30 "'python setup.py build_ext --inplace' to build the C "
---> 31 "extensions first.".format(module))
32
33 from datetime import datetime
ImportError: C extension: hashtable not built. If you want to import
pandas from the source directory, you may need to run 'python setup.py
build_ext --inplace' to build the C extensions first.
but I can import numpy, scipy,sklearn correctly
import scipy as sp
import numpy as np
import sklearn as sk
In addition, if I use Spyder or ipython on Anaconda, it works for all the 6 packages mentioned above. I used the Mac OS 10.10.5, Python 2.7.12 Anaconda 2 (x86_64). The question is similar to the question mentioned in the following link, but the answer seems not work for my problem (I have deleted the python 2.7 installed on the Mac by default).
Import pandas on jupyter ipython notebook fails
uninstall and reinstall pandas and try again. Also if there are useless files in your directory delete them.

training SyntaxNet from parser_trainer_test.sh (ImportError: cannot import name tf_logging)

I am new to python and SyntaxNet and I am trying to train SyntaxNet from SyntaxNet Tutorial.
To trained the model I updated parser_trainer_test.sh based on The Tutorial. and ran it as follow:
ubuntu#ubuntu-VirtualBox:~/models/syntaxnet$ syntaxnet/parser_trainer_test.sh
It gave me this error:
syntaxnet/parser_trainer_test.sh: line 36: /home/ubuntu/models/syntaxnet/syntaxnet/parser_trainer: No such file or directory
Then I updated "$BINDIR/parser_trainer" \ in line 35 of parser_trainer_test.sh to "$BINDIR/parser_trainer.py" \ and ran it again.
And it gave me this error:
File "/home/ubuntu/models/syntaxnet/syntaxnet/parser_trainer.py", line 25,in <module>
from tensorflow.python.platform import tf_logging as logging
ImportError: cannot import name tf_logging
I went through tf_logging.py and all other python files in syntaxnet/tensorflow/python/platform
I think that's where the error is. But if you want, I can post more.
parser.trainer.py :
import os
import os.path
import time
import tensorflow as tf
from tensorflow.python.platform import tf_logging as logging # this is where error happens
from tensorflow.python.platform import gfile
tf_logging.py:
import logging
import os
import sys
import time
from logging import DEBUG
from logging import ERROR
from logging import FATAL
from logging import INFO
from logging import WARN
There is something that I am suspecious about (I am not perofessional so sorry if it seems silly). I found a file named logging.hin path tensorflow/tensorflow/core/platform which defines DEBUG,ERROR,FATAL,.. and I get confused whether the aim of the model is the logging package from python or this logging.h file. If am wrong, which is probable, please help me through this problem.
I suspect the problem is that you are trying to run the script directly, and it expects to be invoked by Bazel (so that the environment, paths, etc. are set up appropriately). Try the following command instead:
$ bazel test //syntaxnet:parser_trainer_test

Import error for numpy

I downloaded numpy1.8 for python 2.7
Installed fine, but when i give:
from numpy.fft import fft, fftfreq
it gives me a huge error, which ends with
from numpy.core.multiarray import (
ImportError: cannot import name datetime_data
How can i get rid of this error ?
I need numpy to perform fft functions.
Any kind of help is appreciated.