I'm having issues getting cx_freeze to build my program, so I started afresh and discovered the issue was with PyQt5. I stripped down the code to this
import os
import sys
from PyQt5 import QtWidgets
print("program ran!")
The setup.py looks like this:
from setuptools import find_packages
from cx_Freeze import setup, Executable
options = {
'build_exe': {
'includes': [
],
'packages': [
'PyQt5.QtCore', 'PyQt5.QtGui', 'PyQt5.QtWidgets'
],
'excludes': [
]
}
}
executables = [
Executable('test2.py',
base=None,
targetName='program.exe')
]
setup(
name='program',
packages=find_packages(),
version='0.1',
description='PCPRo 2022',
executables=executables,
options=options
)
I build the program using the command python setup.py build
When I run the resulting .exe I get the error:
Fatal Python error: _PyInterpreterState_Get(): no current thread state
Python runtime state: unknown
If I remove the line from PyQt5 import QtWidgets and rebuild, the program runs as expected.
I am using Python 3.7.4 [MSC v.1916 64 bit (AMD64)] on win32
Related
I have setup a Gradle project to automate an Android application using Cucumber and Appium with Java. I also wanted to use POM to capture the elements page-wise. The project structure looks like:
I wants to add Extent Report to get testcase execution status. Now when i am running CukesRunner file:
package runners;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
#RunWith(Cucumber.class)
#CucumberOptions(
plugin = {
"json:target/cucumber.json",
"html:target/default-html-reports",
"rerun:target/rerun.txt"
},
features = {"src//test//resources//Features"},
glue = {"stepdefinition"},
dryRun = false,
tags = "#paybackTest"
)
public class CukesRunner {
}
It displays the exit code 0 error with some unknown error:
My appium server is running on 127.0.0.1:4723 and also an Android device connected through USB (i cross-checked it with 'adb devices').
I have created my own Julia package and I am new to such practices.
I previously had this code:
using Parameters
#with_kw mutable struct MWE #deftype String
mwe1 = "default" ; #assert mwe1 in ["default", "1", "2"]
mwe2 = "test"
end
Which worked well. Now that I put it into my package, replacing using with import, I have the following error:
julia> import MyPackageMWE
[ Info: Precompiling RobustRSP [33e6bdf6-6d3e-458b-9f4e-8cd6eb784281]
[ Info: Loading JuMP
[ Info: Loading Gurobi
[ Info: Loading Combinatorics, DelimitedFiles, Dates and Random
[ Info: Loading Distributions, Graphs and Plots
[ Info: Loading Parameters and Formatting
[ Info: Loading Compose, Cairo and Fontconfig
[ Info: Loading .jl files 0%
ERROR: LoadError: UndefVarError: #with_kw not defined
Any ideas what went wrong?
Maybe it is related to #macros?
I don't know the package Parameters but it may be that if #with_kw is exported in Parameters then if you replace
using Parameters
with
import Parameters
then you should change
#with_kw with Parameters.#with_kw
I am trying to implement phantom js in angular 8 application by following below steps:
npm install karma-phantomjs-launcher --save-dev
npm install intl --save
Add import 'core-js/client/shim'; and import intl; to polyfills.ts.
I am getting following syntax error on running ng test:
SyntaxError: Use of reserved word 'class'
at http://localhost:9876/_karma_webpack_/polyfills.js:22707:0
Kindly guide me for this issue.
Thanks
Set the target in tsconfig.spec.json to es5 instead of the default es6
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/spec",
"baseUrl": "./",
"types": [
"jasmine",
"node"
],
"target": "es5", <<<========== add this line
},
Add the following to your polyfills.ts file:
import 'core-js/es6/symbol';
import 'core-js/es6/object';
import 'core-js/es6/function';
import 'core-js/es6/parse-int';
import 'core-js/es6/parse-float';
import 'core-js/es6/number';
import 'core-js/es6/math';
import 'core-js/es6/string';
import 'core-js/es6/date';
import 'core-js/es6/array';
import 'core-js/es6/regexp';
import 'core-js/es6/map';
import 'core-js/es6/weak-map';
import 'core-js/es6/set';
I want to include a README.md file with my module package for PyPI such that it can be read by a function in my setup.py. However, it is not obvious to me how to get setup.py and related infrastructure to actually include the README.md file.
I have included a MANIFEST.in file in my package that itself lists README.md and I have set the setuptools.setup argument include_package_data to True but this has not worked.
manifest.in:
junkmodule.py
junkmodule_script.py
LICENSE
MANIFEST.in
README.md
setup.py
setup.py:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import pypandoc
import setuptools
def main():
setuptools.setup(
name = "junkmodule",
version = "2017.01.13.1416",
description = "junk testing module",
long_description = pypandoc.convert("README.md", "rst"),
url = "https://github.com/user/junkmodule",
author = "LRH",
author_email = "lhr#psern.ch",
license = "GPLv3",
include_package_data = True,
py_modules = [
"junkmodule"
],
install_requires = [
"numpy"
],
scripts = [
"junkmodule_script.py"
],
entry_points = """
[console_scripts]
junkmodule = junkmodule:junkmodule
"""
)
if __name__ == "__main__":
main()
The commands I use to register and upload the module to PyPI are as follows:
python setup.py register -r https://pypi.python.org/pypi
python setup.py sdist upload -r https://pypi.python.org/pypi
I'm using this in my modules, try:
import pypandoc
try:
description=pypandoc.convert('README.md', 'rst')
except (IOError, ImportError):
description=open('README.md').read()
I'm trying to freeze a small GUI I made using PyQT5, Matplolib and Python 3.3.
I'm a beginner so please pardon my ignorance.
The program has:
- one QMainWindow
- two auxiliary QDialogs with Matplotlib plots
- one Variables_Module that I use to store variables (rather than using global)
- one custom Class called ROI
When running from Python terminal the code works fine.
Issue: When running the exe obtained with cx_freeze QMainWindow is loaded, user chooses data and data is immediately shown in first QDialog. Second QDialog uses variables stored in the "Variables_Module" and should show a matplotlib hist2d but nothing appears.
For this reason I think Variables_Modules does not get included in the build somehow.
the Main.py has these includes:
import sys, time
from PyQt5.QtCore import Qt, pyqtSignal, QObject
from PyQt5.QtWidgets import QWidget, QApplication, QMainWindow, QFormLayout, QVBoxLayout,QFileDialog, QDialog, QPushButton, QGridLayout, QMessageBox, QSlider, QSpinBox, QGroupBox, QLabel, QCheckBox, QComboBox, QColorDialog, QProgressDialog
from HySP_main_GUI import Ui_Main
import numpy
from matplotlib.pylab import *
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QTAgg as NavigationToolbar
from matplotlib.figure import Figure
import matplotlib.pyplot as pyplot
#these are the "custom" modules
import Variables_Module
from ROI import Resizable_animated_rect
from scipy import ndimage
I tried including the "custom" modules in the setup.py in every combination as Includes or includefiles or packages with no solution.
I do understand I'm not supposed to put these modules everywhere but I'm out of ideas.
Also, all files (Main.py, ROI.py, Variables_Module.py) are in the same folder and no errors are given when running cx_freeze build.
The setup.py I'm using is:
import sys
from cx_Freeze import setup, Executable
includes = ["ROI","Variables_Module"]
includefiles = ['ROI.py','Variables_Module.py']
excludes = [ 'Tkinter']
packages = ["ROI","Variables_Module"]
path = []
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {
"includes": includes,
"include_files": includefiles,
"excludes": excludes,
"packages": packages,
"path": path
}
# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
exe = None
if sys.platform == "win32":
exe = Executable(
script="E:\\Python\\Projects\\test\\test.py",
initScript = None,
base="Win32GUI",
compress = True,
copyDependentFiles = True,
appendScriptToExe = False,
appendScriptToLibrary = False,
icon = None
)
setup(
name = "test",
version = "0.1",
author = 'test',
description = "My GUI!",
options = {"build_exe": build_exe_options},
executables = [exe]
)
It would appear that warnings halt the frozen exe.
Before plotting my new image some warnings regarding NaN were shown and apparently were preventing the app from going on with calculations.
I solved suppressing the warning in the troublesome function using:
import warnings
warnings.simplefilter("ignore")
this solves the problem. Took 2 days. -_-'