PyInstaller and PySide and QtGui - pyside

I'm having a similar problem to the post:
Pyinstaller: ImportError: cannot import name QtGui
... however this post does not appear to have a solution. I cannot use pyinstaller to install the very simply PySide script (helloWorld.py):
#!/usr/bin/python
import sys
from PySide import QtGui
from PySide import QtCore
app = QtGui.QApplication(sys.argv)
label = QtGui.QLabel("Hello Plain World")
label.show()
app.exec_()
sys.exit()
I run:
]$ ./makespec.py -F helloWorld.py
]$ pyinstaller helloWorld.Spec
which generates:
fatal: Not a git repository (or any of the parent directories): .git
20 INFO: UPX is not available.
34 INFO: Processing hook hook-os
103 INFO: Processing hook hook-time
104 INFO: Processing hook hook-cPickle
156 INFO: Processing hook hook-_sre
245 INFO: Processing hook hook-cStringIO
308 INFO: Processing hook hook-encodings
316 INFO: Processing hook hook-codecs
599 INFO: Extending PYTHONPATH with /home/derek/BitBucketRepos/tmp/qvt/pyinstaller/tmp
599 INFO: checking Analysis
599 INFO: building Analysis because out00-Analysis.toc non existent
599 INFO: running Analysis out00-Analysis.toc
632 INFO: Analyzing /home/derek/BitBucketRepos/tmp/qvt/pyinstaller/PyInstaller/loader /_pyi_bootstrap.py
643 INFO: Processing hook hook-os
652 INFO: Processing hook hook-site
661 INFO: Processing hook hook-encodings
726 INFO: Processing hook hook-time
727 INFO: Processing hook hook-cPickle
780 INFO: Processing hook hook-_sre
871 INFO: Processing hook hook-cStringIO
939 INFO: Processing hook hook-codecs
1272 INFO: Processing hook hook-pydoc
1358 INFO: Processing hook hook-email
1398 INFO: Processing hook hook-httplib
1430 INFO: Processing hook hook-email.message
1476 INFO: Analyzing /home/derek/BitBucketRepos/tmp/qvt/pyinstaller/PyInstaller/loader /pyi_importers.py
1515 INFO: Analyzing /home/derek/BitBucketRepos/tmp/qvt/pyinstaller/PyInstaller/loader /pyi_archive.py
1542 INFO: Analyzing /home/derek/BitBucketRepos/tmp/qvt/pyinstaller/PyInstaller/loader /pyi_carchive.py
1570 INFO: Analyzing /home/derek/BitBucketRepos/tmp/qvt/pyinstaller/PyInstaller/loader /pyi_os_path.py
1573 INFO: Analyzing helloWorld.py
1575 INFO: Processing hook hook-PySide
1575 INFO: Hidden import 'codecs' has been found otherwise
1575 INFO: Hidden import 'encodings' has been found otherwise
1575 INFO: Looking for run-time hooks
objdump: section '.dynamic' mentioned in a -j option, but not found in any input file
2579 INFO: Using Python library /usr/lib/libpython2.7.so.1.0
2579 INFO: Adding Python library to binary dependencies
2964 INFO: Warnings written to /home/derek/BitBucketRepos/tmp/qvt/pyinstaller/tmp/build /helloWorld/warnhelloWorld.txt
2968 INFO: checking PYZ
2968 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing
2968 INFO: building PYZ (ZlibArchive) out00-PYZ.toc
3329 INFO: checking PKG
3329 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing
3329 INFO: building PKG (CArchive) out00-PKG.pkg
objdump: section '.dynamic' mentioned in a -j option, but not found in any input file
10614 INFO: checking EXE
10614 INFO: rebuilding out00-EXE.toc because helloWorld missing
10614 INFO: building EXE from out00-EXE.toc
10614 INFO: Appending archive to EXE /home/derek/BitBucketRepos/tmp/qvt/pyinstaller /tmp/dist/helloWorld
This successfully produces an executable but when I run it I get the following output:
Traceback (most recent call last):
File "<string>", line 4, in <module>
ImportError: cannot import name QtGui
My system is Linux Mint 15 (ubuntu 13.04), have PySide and PySide-dev installed and used quite a bit, I am using pyinstaller 2.0.
Any help would be GREATLY appricated.
Derek

This is likely related to hidden imports that the analysis cannot detect. From the manual:
If Analysis thinks it has found all the imports, but the app fails
with an import error, the problem is a hidden import; that is, an
import that is not visible to the analysis phase. Hidden imports can
occur when the code is using import or perhaps exec or eval. You
get warnings of these (see Build-time Messages). Hidden imports can
also occur when an extension module uses the Python/C API to do an
import. When this occurs, Analysis can detect nothing. There will be
no warnings, only a crash at run-time. To find these hidden imports,
set the -v flag (Getting Python's Verbose Imports above). Once you
know what they are, you add the needed modules to the bundle using the
--hidden-import= command option, by editing the spec file, or with a hook file (see Using Hook Files below).
Try adding the following to your spec file's Analysis section:
hiddenimports=['PySide.QtCore','PySide.QtGui']

Related

Build Docker Images with Bazel targets Built

I have a (1) Dockerfile and a (2) C++ project with Bazel
I want to create a docker image that has Bazel targets pre-built within the image, so as to when I power up new containers the Bazel targets are pre-built and I just do Bazel run //hello:hello_world from the container bash.
Dockerfile
# Copy my project with Bazel files to a Docker image, and the
...
RUN bazel --output_user_root=/tmp/hello_project/bazel build //...
...
Within the execution of the Dockerfile, I get the following output which is expected
Loading:
Loading: 0 packages loaded
Analyzing: 2 targets (1 packages loaded, 0 targets configured)
Analyzing: 2 targets (11 packages loaded, 18 targets configured)
INFO: Analyzed 2 targets (15 packages loaded, 60 targets configured).
INFO: Found 2 targets...
[0 / 11] [Prepa] BazelWorkspaceStatusAction stable-status.txt
INFO: Elapsed time: 6.333s, Critical Path: 0.37s
INFO: 11 processes: 6 internal, 5 processwrapper-sandbox.
INFO: Build completed successfully, 11 total actions
INFO: Build completed successfully, 11 total actions
When I run a new container form the Docker Image built previously and then on the container I run
bazel run //hello:hello_world
Instead of using existing pre-built targets it re-builds the targets, which is not required.
Result I expect (not get): Everything is pre-built and just needs to run
INFO: Analyzed target //hello:hello_world (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //hello:hello_world up-to-date:
bazel-bin/hello/hello_world
INFO: Elapsed time: 0.163s, Critical Path: 0.01s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build completed successfully, 1 total action
Hello World!
Result I get: I re-builds the binaries
[root#4a6bdb57fd79 test-rc]# bazel run //hello:hello_world
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
INFO: Analyzed target //hello:hello_world (15 packages loaded, 60 targets configured).
INFO: Found 1 target...
Target //hello:hello_world up-to-date:
bazel-bin/hello/hello_world
INFO: Elapsed time: 6.255s, Critical Path: 0.38s
INFO: 7 processes: 4 internal, 3 processwrapper-sandbox.
INFO: Build completed successfully, 7 total actions
INFO: Build completed successfully, 7 total actions
Hello World!
How can I make sure, the the bazel run uses same pre-built targets and not build them again before run.
This sounds like non-determinism - in the second execution of Bazel, something is different causing a cache miss.
Some things that can cause it:
different options passed to bazel build vs. bazel test - check your .bazelrc file
actions that include VCS info or a timestamp - make sure you have rules_docker 0.22.0 or later to pick up https://github.com/bazelbuild/rules_docker/commit/2b35b2dd56f0be6cc6b8df957332a31435f6b3ce
One step to diagnose is to use the --explain=log.txt and --verbose_explanations flags to Bazel, then the log file will say why it was rebuilt. However it doesn't have much detail, just something like "a source file has changed".
If you want the power tool for this, there is a way to find out exactly why Bazel didn't get a cache hit - read https://georgi.hristozov.net/til/2020/04/20/compare-bazel-execlogs-to-find-non-deterministic-parts-of-the-build

Golang Bazel empty coverage_report.dat

I am working on a small Golang monorepo and I am using Bazel + gazelle to manage deps along with tests, builds, coverage,...
I am having an issue when it comes to coverage. I have followed a few examples but for some reason the coverage_report.dat file (that then will be processed by genhtml) is always empty.
This is the command that I am running with relative output
$ bazel coverage --combined_report=lcov --cache_test_results=no --test_output=all //...
INFO: Using default value for --instrumentation_filter: "^//service/hello[/:],^//service/hellotwo[/:]".
INFO: Override the above default with --instrumentation_filter
INFO: Analyzed 4 targets (0 packages loaded, 0 targets configured).
INFO: Found 2 targets and 2 test targets...
INFO: From Testing //service/hello:hello_test:
==================== Test output for //service/hello:hello_test:
PASS
coverage: 100.0% of statements
================================================================================
INFO: From Testing //service/hellotwo:hellotwo_test:
==================== Test output for //service/hellotwo:hellotwo_test:
PASS
coverage: 100.0% of statements
================================================================================
INFO: LCOV coverage report is located at /private/var/tmp/_bazel_andrea/292e77b095155ea362773b482c2c4621/execroot/__main__/bazel-out/_coverage/_coverage_report.dat
and execpath is bazel-out/_coverage/_coverage_report.dat
INFO: Elapsed time: 0.217s, Critical Path: 0.09s
INFO: 3 processes: 1 internal, 2 darwin-sandbox.
INFO: Build completed successfully, 3 total actions
//service/hello:hello_test PASSED in 0.1s
/private/var/tmp/_bazel_andrea/292e77b095155ea362773b482c2c4621/execroot/__main__/bazel-out/darwin-fastbuild/testlogs/service/hello/hello_test/coverage.dat
//service/hellotwo:hellotwo_test PASSED in 0.1s
/private/var/tmp/_bazel_andrea/292e77b095155ea362773b482c2c4621/execroot/__main__/bazel-out/darwin-fastbuild/testlogs/service/hellotwo/hellotwo_test/coverage.dat
Executed 2 out of 2 tests: 2 tests pass.
INFO: Build completed successfully, 3 total actions
The coverage is calculated but bazel-out/_coverage/_coverage_report.dat is empty. I was wondering if anyone has had this issue before and managed to find a solution to it.
I am working on a MacBook Pro with Bazel (v4.1.0) installed via Homebrew.

Can't build a standalone .exe with the module pdftotext

I'm trying to convert my python script, which contains the module pdftotext, into a standalone .exe.
When I test the .exe app in my anaconda env It works correctly but when I test it on another device It gaves me this error:
File "main.py", line 3, in <module> #line 3 is import pdftotext
"ImportError: DLL load failed: The specified module could not be found"
[7300] Failed to execute script main
I'm sure the problem concern the module pdftotext because I tried with the simple script below and works correctly:
a=input("Start")
print("Hello world")
b=input("End")
The error appears if I convert this script:
import pdftotext
a=input("Inserisci")
print("Hello world")
b=input("Fine")
Sorry for my poor english, I come from Italy. I hope I'm making myself clear, thanks to everyone
EDIT 1. I figured out the problem may be related to poppler (library used by pdftotext) but at the moment I can't understand which file hooks up to import poppler
EDIT 2. After some work I found out two thing that might help to understand better my situation:
The .exe application works on my device (even outside the anaconda env where I've installed poppler and pdftotext) but It doesn't work on others devices (I've tried two different windows laptop and the error is the same); the script without 'pdftotext' work on every devices
In the dist folder (build by pyinstaller) appears a single file with
the name pdftotext: the file is 'pdftotext.cp37-win_amd64.pyd' (i'm
not sure what is it). In my anaconda env there are only two file
which contains the string 'pdftotext': the files are
'pdftotext.cp37-win_amd64.pyd' and 'pdftotext.exe'
EDIT 3
Full error when I run main.exe on different device :
Traceback (most recent call last):
File "main.py",line 1, in <module>
ImportError: DLL load failed: The specified module could not be found
[7140] Failed to execute script main
Full pyinstaller log:
(envPDF) C:\Users\miche\Desktop\project>pyinstaller --additional-hooks-dir=hooks main.py
65 INFO: PyInstaller: 3.6
65 INFO: Python: 3.7.6 (conda)
65 INFO: Platform: Windows-10-10.0.18362-SP0
65 INFO: wrote C:\Users\miche\Desktop\project\main.spec
65 INFO: UPX is not available.
81 INFO: Extending PYTHONPATH with paths
['C:\\Users\\miche\\Desktop\\project', 'C:\\Users\\miche\\Desktop\\project']
81 INFO: checking Analysis
81 INFO: Building Analysis because Analysis-00.toc is non existent
81 INFO: Initializing module dependency graph...
81 INFO: Caching module graph hooks...
81 INFO: Analyzing base_library.zip ...
3232 INFO: Caching module dependency graph...
3326 INFO: running Analysis Analysis-00.toc
3343 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
required by c:\users\miche\anaconda3\envs\envpdf\python.exe
3608 INFO: Analyzing C:\Users\miche\Desktop\project\main.py
3624 INFO: Processing module hooks...
3624 INFO: Loading module hook "hook-encodings.py"...
3718 INFO: Loading module hook "hook-pydoc.py"...
3718 INFO: Loading module hook "hook-xml.py"...
3954 INFO: Loading module hook "hook-pdftotext.py"...
6537 INFO: Determining a mapping of distributions to packages...
29442 INFO: Packages required by pdftotext:
[]
33735 INFO: Looking for ctypes DLLs
33735 INFO: Analyzing run-time hooks ...
33746 INFO: Looking for dynamic libraries
34387 INFO: Looking for eggs
34387 INFO: Using Python library c:\users\miche\anaconda3\envs\envpdf\python37.dll
34390 INFO: Found binding redirects:
[]
34395 INFO: Warnings written to C:\Users\miche\Desktop\project\build\main\warn-main.txt
34430 INFO: Graph cross-reference written to C:\Users\miche\Desktop\project\build\main\xref-main.html
35274 INFO: checking PYZ
35274 INFO: Building PYZ because PYZ-00.toc is non existent
35274 INFO: Building PYZ (ZlibArchive) C:\Users\miche\Desktop\project\build\main\PYZ-00.pyz
35794 INFO: Building PYZ (ZlibArchive) C:\Users\miche\Desktop\project\build\main\PYZ-00.pyz completed successfully.
35802 INFO: checking PKG
35802 INFO: Building PKG because PKG-00.toc is non existent
35804 INFO: Building PKG (CArchive) PKG-00.pkg
35824 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
35824 INFO: Bootloader c:\users\miche\anaconda3\envs\envpdf\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
35824 INFO: checking EXE
35824 INFO: Building EXE because EXE-00.toc is non existent
35824 INFO: Building EXE from EXE-00.toc
35824 INFO: Appending archive to EXE C:\Users\miche\Desktop\project\build\main\main.exe
35824 INFO: Building EXE from EXE-00.toc completed successfully.
35875 INFO: checking COLLECT
35875 INFO: Building COLLECT because COLLECT-00.toc is non existent
35875 INFO: Building COLLECT COLLECT-00.toc
96644 INFO: Building COLLECT COLLECT-00.toc completed successfully.
What you need is a hook file for PyInstaller. To quote the documentation:
In summary, a “hook” file extends PyInstaller to adapt it to the special needs and methods used by a Python package. ... ... They help the Analysis phase find needed files.
The official hook docs can be found at https://pyinstaller.readthedocs.io/en/stable/hooks.html.
Edit: the following should work:
Create this directory structure:
- yourcode.py
- hooks
- hook-pdftotext.py
And in the hook file put the following:
from PyInstaller.utils.hooks import collect_all
datas, binaries, hiddenimports = collect_all('pdftotext')
And then build with:
$ pyinstaller --additional-hook-dir=hooks yourcode.py

FHIR IG Publisher templates

This http://ots.nccn.org/documentation/site/StructureDefinition-order-template.xml.html
was generated on Apr 2017 and I have been some updates top the schema. I am new to this process and did some reading and saw this tool org.hl7.fhir.igpublisher that would create the new HTML for me. I download the JAR file and run the command but I am getting this error >Exception in thread "main" java.lang.Error: unknown version 1.9.0
java.exe -jar C:\Project\IGPublisher\org.hl7.fhir.igpublisher.jar -ig "C:\Project\IGPublisher\Publish\ig.json" -watch
FHIR Implementation Guide Publisher (v3.6.0-a77f48d9, gen-code v3.6.0 / 2) # Wednesday, October 17, 2018 1:28:34 PM
Detected Java version: 1.8.0_191 from C:\Program Files\Java\jre1.8.0_191 on amd64 (64bit). 1797MB available
[C:\Project\IGPublisher] -ig C:\Project\IGPublisher\Publish\ig.json -watch
Package Cache: C:\Users\mcdevitt\.fhir\packages
Load Configuration from C:\Project\IGPublisher\Publish\ig.json (00.0020sec)
Root directory: C:\Project\IGPublisher\Publish (00.0106sec)
Terminology Cache is at C:\Project\IGPublisher\Publish\txCache. 243 files in cache (00.0147sec)
Contacting Build Server... (00.0148sec)
... done (01.0177sec)
Exception in thread "main" java.lang.Error: unknown version 1.9.0
at org.hl7.fhir.igtools.publisher.Publisher.getMasterSource(Publisher.java:1460)
at org.hl7.fhir.igtools.publisher.Publisher.loadCorePackage(Publisher.java:1426)
at org.hl7.fhir.igtools.publisher.Publisher.initializeFromJson(Publisher.java:1088)
at org.hl7.fhir.igtools.publisher.Publisher.initialize(Publisher.java:946)
at org.hl7.fhir.igtools.publisher.Publisher.execute(Publisher.java:525)
at org.hl7.fhir.igtools.publisher.Publisher.main(Publisher.java:4927)
Press any key to continue . . .
please take this up on https://chat.fhir.org/#narrow/stream/99-IG-creation (which you have)

compiling SyntaxNet on OS X fails with "error loading package '#jpeg//': Extension file not found"

I can't get SyntaxNet compiled on my MacBook Pro.
I followed the SyntaxNet installation steps here: https://github.com/tensorflow/models/tree/master/syntaxnet#installation
the bazel test --linkopt=-headerpad_max_install_names syntaxnet/... util/utf8/... line fails with this output:
Joachims-MacBook-Pro:syntaxnet joachim$ bazel test --linkopt=-headerpad_max_install_names syntaxnet/... util/utf8/...
ERROR: /private/var/tmp/_bazel_joachim/2d6c6b79fd5d2f10f2fd8d8e3457de30/external/org_tensorflow/tensorflow/core/platform/default/build_config/BUILD:108:1: error loading package '#jpeg//': Extension file not found. Unable to load package for '//third_party:common.bzl': BUILD file not found on package path and referenced by '#org_tensorflow//tensorflow/core/platform/default/build_config:jpeg'.
ERROR: Analysis of target '//syntaxnet:test_main' failed; build aborted.
INFO: Elapsed time: 4.823s
ERROR: Couldn't start the build. Unable to run tests.
Here's some system info:
Joachims-MacBook-Pro:syntaxnet joachim$ bazel version
Build label: 0.4.3-homebrew
Build target: bazel-out/local-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Dec 22 15:20:22 2016 (1482420022)
Build timestamp: 1482420022
Build timestamp as int: 1482420022
Joachims-MacBook-Pro:syntaxnet joachim$ python --version
Python 2.7.11
I pulled the sources as follows:
Joachims-MacBook-Pro:workspace joachim$ git clone --recurse-submodules https://github.com/tensorflow/models.git
Cloning into 'models'
...
'aab099711d7e04034cf742ddb9b00dd15edbe99c'
I encountered a similar problem when compiling on Ubuntu.
Find the file tensorflow/third_party/jpeg/jpeg.BUILD
Then, change the code load("#//third_party:common.bzl", "template_rule")
to
load("#org_tensorflow//third_party:common.bzl", "template_rule")

Resources