Access Violation Error After Cx_Freeze/py2exe Qt5.5.1 App - qt

I used QtDesigner for designing GUI and use pyuic5 for generating python code. After freezing it with cxfreeze or py2exe, app crashes on setupUI function, which is pyuic5 generated. When running app from code, it works as it supposed to. I use python 3.4 (Within Anaconda Distribution) and Qt 5.5.1
The first piece of code that app brokes (which is on setupUI method of main UI):
#Add a QWidget to QTabWidget
self.ModuleListingWidget.addTab(self.MarketingTab, "")
When i use dependencywalker and try to profile the resulted exe it logs following errors:
00:00:00.000: Started "dist\MAIN.EXE" (process 0x2938) at address 0x000C0000. Cannot hook module.
00:00:00.000: Loaded "c:\windows\system32\NTDLL.DLL" at address 0x772C0000. Cannot hook module.
00:00:00.047: Loaded "c:\windows\syswow64\KERNEL32.DLL" at address 0x76CA0000. Cannot hook module.
00:00:00.047: Loaded "c:\windows\syswow64\KERNELBASE.DLL" at address 0x74BF0000. Cannot hook module.
...
00:00:00.125: First chance exception 0xC0000005 (Access Violation) occurred at address 0x721E5B10.
00:00:00.125: Second chance exception 0xC0000005 (Access Violation) occurred at address 0x721E5B10.
Both py2exe and cxfreeze gives same error, 0xC0000005 (Access Violation).
How can i fix this problem, or understand more about the problem itself?
Here is the cxfreeze config:
import sys
from cx_Freeze import setup, Executable
base = "Win32GUI"
path_platforms = ( ".\platforms\qwindows.dll", "platforms\qwindows.dll" )
build_options = {"packages": ['atexit'], "include_files" : [ path_platforms ]}
setup(
name = "myapp",
version = "0.1",
description = "Sample cx_Freeze script",
options = {"build_exe" : build_options},
executables = [Executable("main.py", base = base)]
)
and py2Exe config:
from distutils.core import setup
import py2exe
import sys
sys.argv.append('py2exe')
import glob
import src.MyProj
setup(console=['main.py'], options = {"py2exe": {"typelibs":
# typelib for WMI
[('{565783C6-CB41-11D1-8B02-00600806D9B6}', 0, 1, 2)],
# create a compressed zip archive
"compressed": True,
'bundle_files': 1,
"optimize": 2,
"includes":['sip', "PyQt5", 'PyQt5.QtCore', 'PyQt5.QtWidgets', 'PyQt5.QtGui', 'PyQt5.QtSql']}},
# The lib directory contains everything except the executables and the python dll.
# Can include a subdirectory name.
zipfile = "./shared.zip",
data_files=[
('Images', glob.glob('Images/*.*')),
('sqldrivers', ('C:/Users/user/src/dist/plugins/qsqlmysql.dll',)),
('/c/Python34/Lib/site-packages/PyQt5', ['C:/Python34/Lib/site-packages/PyQt5/Qt5Core.dll'])])

I could not find and solution for that, probably dependency error. Instead i used pyinstaller, and it works like charm.

Related

Failed to execute script due to unhandled exception: No module named ttkwidgets

I created an executable from a py file that used ttkwidgets
import tkinter as tk
import work_logger_database
from ttkwidgets.autocomplete import AutocompleteEntry
root = tk.Tk()
root.geometry('600x300')
items = work_logger_database.show_all()
stored_projects_list = list(set([items[i][2] for i in range(len(items))]))
#or:
#example_list = ['Hello', 'World']
project_entry = AutocompleteEntry(root, completevalues=stored_projects_list)
project_entry.grid(column=0, row=1, sticky='W')
root.mainloop()
and when I open the exe I get what is shown in this image
I also got a warning:
WARNING: Several hooks defined for module 'numpy'. Please take care they do not conflict.
I'm not sure if that's relevant
I tried a solution in creating the exe that didn't work:
pyinstaller work_logger.py --onefile -w --hidden-import=ttkwidgets --hidden-import=ttkwidgets.autocomplete
I also tried:
pyinstaller work_logger.py --onefile -w --hidden-import=ttkwidgets
Had the same ModuleNotFoundError: 'ttkwidgets' creating an executable of one of my scripts.
Worked after (re-)installing ttkwidgets on my system:
pip install ttkwidgets

Atom editor fails installing packages

I'm trying to install packages in Atom editor, but it always fails, just like if I coudn't get a connexion to the server.
For instance, apm install split-diff returns Request for package information failed: getaddrinfo ENOTFOUND atom.io atom.io:443 (ENOTFOUND)
I'm running Atom 1.32.2 on Linux Mint 19.
I don't use a proxy.
Check your DNS servers.
I ran into this problem randomly this afternoon when initially everything was working on my Mac.
I can reach the Internet fine. Github is up and reporting no issues, Atom.io is up...
Clues re:etc/hosts from other comments here pointed me to my my network settings anyway.
Checked and I have my DNS servers configured for VPN access, once I added OpenDNS servers as well, Atom installs starting working again.
Finally, I found out where the bug was!
For some reasons of personal convenience, I replaced /etc/hosts with a symlink (towards some place in my ~/ folder). THIS is what apm didn't like. (No idea why. I'd be glad to know...) Switching back to a real file for /etc/hosts made me able to install packages again.
I just installed split-diff and it loaded fine. Open Atom and under the Atom menu item select Preferences. This opens a new window and on the left side of the pane is a row of actions starting with Core and followed by Editor, URI Handling, and 5 other actions. Click on the Install action. This is where you can find and install extensions. Once you clicked on Install, the pane changes and there is a search box at the top. In the search box type split-diff and the name of your extension should appear. There should be a blue install button for the script. Click install and it should work.
I am on Ubuntu 16.04 and I was having this problem. I had a directory called /etc/hosts/ which was a cloned version of this repo.
Clearly having a directory named the same as a file isn't exactly a smart move, but I was able to solve the problem through moving the directory and running the install script for the repo again. The install script calls a which flushes the DNS file, found in line 1193 of this file here.
I extracted the script/function which should do the trick;
#!/usr/bin/env python3
# Script by Ben Limmer
# https://github.com/l1m5
#
# This Python script will combine all the host files you provide
# as sources into one, unique host file to keep you internet browsing happy.
import argparse
import fnmatch
import json
import locale
import os
import platform
import re
import shutil
import socket
import subprocess
import sys
import tempfile
import time
from glob import glob
import lxml # noqa: F401
from bs4 import BeautifulSoup
# Detecting Python 3 for version-dependent implementations
PY3 = sys.version_info >= (3, 0)
if PY3:
from urllib.request import urlopen
else:
raise Exception("We do not support Python 2 anymore.")
# Syntactic sugar for "sudo" command in UNIX / Linux
if platform.system() == "OpenBSD":
SUDO = ["/usr/bin/doas"]
else:
SUDO = ["/usr/bin/env", "sudo"]
# Project Settings
BASEDIR_PATH = os.path.dirname(os.path.realpath(__file__))
def flush_dns_cache():
"""
Flush the DNS cache.
"""
print("Flushing the DNS cache to utilize new hosts file...")
print(
"Flushing the DNS cache requires administrative privileges. You might need to enter your password."
)
dns_cache_found = False
if platform.system() == "Darwin":
if subprocess.call(SUDO + ["killall", "-HUP", "mDNSResponder"]):
print_failure("Flushing the DNS cache failed.")
elif os.name == "nt":
print("Automatically flushing the DNS cache is not yet supported.")
print(
"Please copy and paste the command 'ipconfig /flushdns' in "
"administrator command prompt after running this script."
)
else:
nscd_prefixes = ["/etc", "/etc/rc.d"]
nscd_msg = "Flushing the DNS cache by restarting nscd {result}"
for nscd_prefix in nscd_prefixes:
nscd_cache = nscd_prefix + "/init.d/nscd"
if os.path.isfile(nscd_cache):
dns_cache_found = True
if subprocess.call(SUDO + [nscd_cache, "restart"]):
print_failure(nscd_msg.format(result="failed"))
else:
print_success(nscd_msg.format(result="succeeded"))
centos_file = "/etc/init.d/network"
centos_msg = "Flushing the DNS cache by restarting network {result}"
if os.path.isfile(centos_file):
if subprocess.call(SUDO + [centos_file, "restart"]):
print_failure(centos_msg.format(result="failed"))
else:
print_success(centos_msg.format(result="succeeded"))
system_prefixes = ["/usr", ""]
service_types = ["NetworkManager", "wicd", "dnsmasq", "networking"]
for system_prefix in system_prefixes:
systemctl = system_prefix + "/bin/systemctl"
system_dir = system_prefix + "/lib/systemd/system"
for service_type in service_types:
service = service_type + ".service"
service_file = path_join_robust(system_dir, service)
service_msg = (
"Flushing the DNS cache by restarting " + service + " {result}"
)
if os.path.isfile(service_file):
dns_cache_found = True
if subprocess.call(SUDO + [systemctl, "restart", service]):
print_failure(service_msg.format(result="failed"))
else:
print_success(service_msg.format(result="succeeded"))
dns_clean_file = "/etc/init.d/dns-clean"
dns_clean_msg = "Flushing the DNS cache via dns-clean executable {result}"
if os.path.isfile(dns_clean_file):
dns_cache_found = True
if subprocess.call(SUDO + [dns_clean_file, "start"]):
print_failure(dns_clean_msg.format(result="failed"))
else:
print_success(dns_clean_msg.format(result="succeeded"))
if not dns_cache_found:
print_failure("Unable to determine DNS management tool.")
You need to use a filter breaker. I had the same problem installing the file_icons package, and the package was installed when the Siphon filter breaker was connected.

How to Export a python project as an executable file? Project is a browser based one

I have a python project which has to be exported in to an executable file so that it can be used in other systems as well. The project has its UI in a browser and runs on localhost.
So far I have tried PyInstaller and cx_Freeze but to no success. I encountered some errors with PyInstaller which I was unable to solve and I switched to cx_Freeze. I was able to freeze the scripts and create a .exe file. But when I open(double click) the .exe file, I get nothing. Not even an error message. I tried running it from command prompt as well, but there too I got no message or output.
Can anyone suggest how my objective can be achieved? Or something needs to be checked?
Here is my setup.py
import sys
import os
from cx_Freeze import setup, Executable
base = None
#if sys.platform == "win32":
# base = "Win32GUI"
os.environ['TCL_LIBRARY']="C:\\Users\\M******\\AppData\\Local\\Continuum\\Anaconda3\\tcl\\tcl8.6"
os.environ['TK_LIBRARY']="C:\\Users\\M******\\AppData\\Local\\Continuum\\Anaconda3\\tcl\\tk8.6"
setup ( name = "Network Analysis",
version = "0.1",
description = "Network Analysis Project",
options = { "build_exe": { "packages" : ['encodings','asyncio','pandas','numpy','geopy','networkx','configparser','json']}},
executables = [Executable("run.py",base=base)])

Apache spark-shell error import jars

I have a local spark 1.5.2 (hadoop 2.4) installation on Windows as explained here.
I'm trying to import a jar file that I created in Java using maven (the jar is jmatrw that I uploaded on here on github). Note the jar does not include a spark program and it has no dependencies to spark. I tried the following steps, but no one seems to work in my installation:
I copied the library in "E:/installprogram/spark-1.5.2-bin-hadoop2.4/lib/jmatrw-v0.1-beta.jar"
Edit spark-env.sh and add SPARK_CLASSPATH="E:/installprogram/spark-1.5.2-bin-hadoop2.4/lib/jmatrw-v0.1-beta.jar"
In a command window I run > spark-shell --jars "E:/installprogram/spark-1.5.2-bin-hadoop2.4/lib/jmatrw-v0.1-beta.jar", but it says "Warning: skip remote jar"
In the spark shell I tried to do scala> sc.addJar("E:/installprogram/spark-1.5.2-bin-hadoop2.4/lib/jmatrw-v0.1-beta.jar"), it says "INFO: added jar ... with timestamp"
When I type scala> import it.prz.jmatrw.JMATData, spark-shell replies with error: not found: value it.
I spent lot of time searching on Stackoverflow and on Google, indeed a similar Stakoverflow question is here, but I'm still not able to import my custom jar.
Thanks
There are two settings in 1.5.2 to reference an external jar. You can add it for the driver or for the executor(s).
I'm doing this by adding settings to the spark-defaults.conf, but you can set these at spark-shell or in SparkConf.
spark.driver.extraClassPath /path/to/jar/*
spark.executor.extraClassPath /path/to/jar/*
I don't see anything really wrong with the way you are doing it, but you could try the conf approach above, or setting these using SparkConf
val conf = new SparkConf()
conf.set("spark.driver.extraClassPath", "/path/to/jar/*")
val sc = new SparkContext(conf)
In general, I haven't enjoyed working with Spark on Windows. Try to get onto Unix/Linux.

When i run the monkey runner, i am getting swt error

I have created the below script and saved it as (test.mr) in the lib folder and running from the command prompt C:\Android_Stuff\android-sdk-windows\tools\lib\monkeyrunner test.mr
#Importing monkeyrunner
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
#waiting for the device connection
device = MonkeyRunner.waitForConnection()
#Installing my app.
device.installPackage('C:/Android_Stuff/android-sdk-windows/tools/lib/purchase.apk')
#starting my demo page
device.startActivity(component='com.mobilemoneynetwork.purchase/.demo')
#selecting the Menu Button.
device.press('KEYCODE_MENU','DOWN_AND_UP')
I am getting
Unable to access jarfile ..\framework\archquery.jar
SWT folder '' does not exist.
Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
Set ANDROID_SWT path in environment variable it should be "your path"\Android\Sdk\tools\lib\x86_64

Resources