Pyinstaller FileNotFoundError: TTF Font file not found: DejaVuSansCondensed.ttf with using --add-data - pyinstaller

I'm trying to compile with pyinstaller a small invoice creater out of a csv.
I have to use a font with UTF-8 because some addresses are from poland.
But somehow i can't include the font properly.
I do it with:
pyinstaller --onefile --windowed --icon icon-pi.icns --add-data /Users/XXXX/Documents/XXXX-OÜ/Script/Proforma/DejaVuSansCondensed.ttf:DejaVuSansCondensed.ttf Proforma.py
The Error-message is:
Traceback (most recent call last):
File "Proforma.py", line 445, in <module>
File "Proforma.py", line 221, in pdf_footer
File "fpdf/fpdf.py", line 1465, in add_font
FileNotFoundError: TTF Font file not found: DejaVuSansCondensed.ttf
[7085] Failed to execute script 'Proforma' due to unhandled exception!
At some point it actually worked with the font, then I saw some minor mistakes in the code, which i fixed (but should normally don't have any influence on the pyinstaller)
And now I don't know what I did wrong but somehow it doesn't work anymore.
Before there was an space between XXXX and OÜ (in /Users/XXXX/Documents/XXXX-OÜ/) so I even changed the directory to the "-" in between which lead to, that I configured a new interpreter and in the end a total new file
(I'm saying this just in case this could be a source of it)
Also the font DejaVuSansCondensed.ttf is in the same folder as Proforma.py
I would be really happy about any suggestions :)

Related

(.py) got converted to exe but while executing fails to find ib\ext\anywrapper.py ... (IBPY)

I am using interactive broker api - ibpy. I have generated an executable using pyinstaller as well as cx_freeze.
The executable gets created in both the cases but while executing it gives the same error that it could not find the file ib\ext\AnyWrapper.py.
File "lib\site-packages\ib\opt\message.py", line 153, in <module>
File "lib\site-packages\ib\opt\message.py", line 31, in __ init__
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\admin\\AppData\\Local\\Temp\\_MEI27882\\ib\\ext\\AnyWrapper.py'
In the above example, the temp folder gets deleted, but while using cx_freeze it could see that the file ib\ext\AnyWrapper.pyc existed.
Could this be some error in ib\opt\message.py itself while looking for AnyWrapper? Should it be looking for AnyWrapper and not AnyWrapper.py?
Is it a bug with IBPY or is it something else?

Error while running depswriter.py from google closure library

I am trying to build XTK following this link on Linux running on Oracle VirtualBox to get non-minified xtk.js. I am getting following error when I tried to generate the xtk-deps.js on running deps.py file:
Generating dependency file for XTK...
Traceback (most recent call last):
File "/root/Downloads/X-master/lib/google-closure-library/closure/bin/build/depswriter.py", line 212, in <module>
main()
File "/root/Downloads/X-master/lib/google-closure-library/closure/bin/build/depswriter.py", line 196, in main
path_to_source[depspath] = source.Source(source.GetFileContents(srcpath))
File "/root/Downloads/X-master/lib/google-closure-library/closure/bin/build/source.py", line 126, in GetFileContents
return fileobj.read()
File "/usr/lib/python2.7/codecs.py", line 668, in read
return self.reader.read(size)
File "/usr/lib/python2.7/codecs.py", line 474, in read
newchars, decodedbytes = self.decode(data, self.errors)
File "/usr/lib/python2.7/encodings/utf_8_sig.py", line 104, in decode
return codecs.utf_8_decode(input, errors)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x9a in position 4584: invalid start byte
Could not generate dependency file.
Could anybody please explain why this error is coming.
There's probably some non-uft8 characters in your code (most likely in X.js).
Take my experience for example, in the X.js of XTK, I found there's a non-English word (maybe a German or French name) in line #210. What I did is to delete the character and run build.py again. The encode error didn't appear again.
What worked for me is that I used an earlier commit of google closure library for building XTK and it worked perfectly.
I had to search XTK's commit history extensively to know which version of closure library they were using to build it.
PS: Earlier I posted similar solution here. But the post was deleted by moderator so sharing it here again.

TypeError: Expected bytes While printing Any Report Using Client Database in OpenERP 7.0

I am using Client Database and it will be restored successfully in my local system and working fine but when I am printing any report the within that database at that time.
I got the below traceback from the terminal.
Traceback (most recent call last):
File "/home/best/workspace/dynaweld/web/addons/web/http.py", line 285, in dispatch
r = method(self, **self.params)
File "/home/best/workspace/dynaweld/web/addons/web/controllers/main.py", line 1769, in index
cookies={'fileToken': int(token)})
File "/home/best/workspace/dynaweld/web/addons/web/http.py", line 332, in make_response
response.set_cookie(k, v)
File "/usr/local/lib/python2.7/dist-packages/Werkzeug-0.10.4-py2.7.egg/werkzeug/wrappers.py", line 1008, in set_cookie
self.charset))
File "/usr/local/lib/python2.7/dist-packages/Werkzeug-0.10.4-py2.7.egg/werkzeug/http.py", line 920, in dump_cookie
value = to_bytes(value, charset)
File "/usr/local/lib/python2.7/dist-packages/Werkzeug-0.10.4-py2.7.egg/werkzeug/_compat.py", line 106, in to_bytes
raise TypeError('Expected bytes')
TypeError: Expected bytes
I have tried the following way to resolve above traceback issue but I have not yet succeed.
1. Try remove the unwanted data from my local client database remove the all the data of mail.message object.
2. Remove all the unnecessary database from my system and using only 2-3 database for my OpenERP Server Run.
3. Clean my pc for unwanted files and other detail which was not relevant for my database.
4. I have also check with my enough memory space but I have that enough space for restoring that database file.
Can any one help me how can i fix this issue.
This is because cookies are not intended to support unicode characters, you must use a decoded variable in the cookie you are trying to set. something like :
set_cookie(k, bytes(v))
or at least send your variable as bytes.
I have fixed this by installing an older version of werkzeug, 0.6.2

Plone 4.3 AssertionError Running Buildout

We recently got a new Linux machine that got re-imaged from our older machine where our current plone installation resides. I am trying to run buildout on the new machine but I am getting this AssertionError on our plonetheme src product.
Installing 'buildout.dumppickedversions', 'buildout.sanitycheck'.
We have the distribution that satisfies 'buildout.dumppickedversions==0.5'.
Picked: buildout.sanitycheck = 1.0b1
Develop: '/var/db/zope/plone43/zeocluster/src/products.okctypes'
in: '/var/db/zope/plone43/zeocluster/src/products.okctypes'
/tmp/tmpVPeu_l -q develop -mxN -d /var/db/zope/plone43/zeocluster/develop-eggs/tmp4eer1vbuild
Develop: '/var/db/zope/plone43/zeocluster/src/plonetheme.ourtheme'
in: '/var/db/zope/plone43/zeocluster/src/plonetheme.ourtheme'
/tmp/tmppWGq8Z -q develop -mxN -d /var/db/zope/plone43/zeocluster/develop-eggs/tmpUl2ukSbuild
No local packages or download links found for PasteScript
Traceback (most recent call last):
File "/tmp/tmppWGq8Z", line 11, in <module>
execfile('/var/db/zope/plone43/zeocluster/src/plonetheme.ourtheme/setup.py')
File "/var/db/zope/plone43/zeocluster/src/plonetheme.ourtheme/setup.py", line 37, in <module>
paster_plugins=["ZopeSkel"],
File "/var/db/zope/plone43/Python-2.7/lib/python2.7/distutils/core.py", line 112, in setup
_setup_distribution = dist = klass(attrs)
File "/var/db/zope/plone43/buildout-cache/eggs/distribute-0.6.28-py2.7.egg/setuptools/dist.py", line 221, in __init__
self.fetch_build_eggs(attrs.pop('setup_requires'))
File "/var/db/zope/plone43/buildout-cache/eggs/distribute-0.6.28-py2.7.egg/setuptools/dist.py", line 245, in fetch_build_eggs
parse_requirements(requires), installer=self.fetch_build_egg
File "/var/db/zope/plone43/buildout-cache/eggs/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 580, in resolve
dist = best[req.key] = env.best_match(req, self, installer)
File "/var/db/zope/plone43/buildout-cache/eggs/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 825, in best_match
return self.obtain(req, installer) # try and download/install
File "/var/db/zope/plone43/buildout-cache/eggs/distribute-0.6.28-py2.7.egg/pkg_resources.py", line 837, in obtain
return installer(requirement)
File "/var/db/zope/plone43/buildout-cache/eggs/distribute-0.6.28-py2.7.egg/setuptools/dist.py", line 294, in fetch_build_egg
return cmd.easy_install(req)
File "/var/db/zope/plone43/buildout-cache/eggs/distribute-0.6.28-py2.7.egg/setuptools/command/easy_install.py", line 592, in easy_install
raise DistutilsError(msg)
distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('PasteScript')
While:
Installing.
Processing develop directory '/var/db/zope/plone43/zeocluster/src/plonetheme.ourtheme'.
An internal error occurred due to a bug in either zc.buildout or in a
recipe being used:
Traceback (most recent call last):
File "/var/db/zope/plone43/buildout-cache/eggs/zc.buildout-1.7.1-py2.7.egg/zc/buildout/buildout.py", line 1866, in main
getattr(buildout, command)(args)
File "/var/db/zope/plone43/buildout-cache/eggs/zc.buildout-1.7.1-py2.7.egg/zc/buildout/buildout.py", line 487, in install
installed_develop_eggs = self._develop()
File "/var/db/zope/plone43/buildout-cache/eggs/zc.buildout-1.7.1-py2.7.egg/zc/buildout/buildout.py", line 727, in _develop
zc.buildout.easy_install.develop(setup, dest)
File "/var/db/zope/plone43/buildout-cache/eggs/zc.buildout-1.7.1-py2.7.egg/zc/buildout/easy_install.py", line 1184, in develop
*args) == 0
AssertionError
*************** PICKED VERSIONS ****************
[versions]
*************** /PICKED VERSIONS ***************
Our Product's init.py script contains the following:
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
I've seen a similar error reported here but the answer provided does not apply to our case. We have other products in src but this is the only one causing problems.
Can someone please help us with this error?
Check the setup.py file in your theme package. You'll likely find:
# The next two lines may be deleted after you no longer need
# addcontent support from paster and before you distribute
# your package.
setup_requires=["PasteScript"],
paster_plugins = ["ZopeSkel"],
Remove those lines. They are included in the generated template for your package so that you may use Zopeskel local commands to add new functionality. You don't need it after development, and it's often a source of problems later.
The alternative solution, as mentioned in the comments, is to make sure you have the right egg in your local buildout cache. But why have old development packages sitting around on a live site?

Send as PDF add-on in plone not working

I'm new to plone and im trying to get the send as PDF add on to work. I have added:
pisa
pyPdf
html5lib
reportlab
to the buildout file and have configured the collective.sendaspdf send as PDF add-on. Whenever I try click on the send as PDF option, it does nothing. Help will be appreciated.
The traceback in the error log has the following information:
Exception Value
'ascii' codec can't decode byte 0xe2 in position 8192: ordinal not in range(128)
Traceback (innermost last):
Module ZPublisher.Publish, line 126, in publish
Module ZPublisher.mapply, line 77, in mapply
Module ZPublisher.Publish, line 46, in call_object
Module jquery.pyproxy.plone, line 66, in _jquery
Module collective.sendaspdf.browser.ajax, line 56, in show_send_form
Module collective.sendaspdf.browser.ajax, line 44, in _show_send_form
Module collective.sendaspdf.browser.base, line 237, in make_pdf
Module collective.sendaspdf.browser.base, line 223, in generate_pdf_file
Module collective.sendaspdf.transforms.pisa, line 16, in html_to_pdf
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 8192: ordinal not in range(128)
When I try to install wkhtmltopdf through build out by using bin/buildout after modifying the buildout.cfg file, I get the following error:
While:
Installing.
Error: Missing option: buildout:parts
****** PICKED VERSIONS *******
[versions]
****** /PICKED VERSIONS ******
I have done everything it says in this link: https://github.com/vincent-psarga/collective.sendaspdf
I have made the following changes in my buildout file(buildout.cfg):
parts =
instance
zopepy
zopeskel
unifiedinstaller
repozo
backup
chown
wkhtmltopdf
wkhtmltopdf_executable
environment-vars =
zope_i18n_compile_mo_files true
PYTHON_EGG_CACHE ${buildout:directory}/var/.python-eggs
WKHTMLTOPDF_PATH ${buildout:directory}/wkhtmltopdf
[wkhtmltopdf]
recipe = hexagonit.recipe.download
url = http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-amd64.tar.bz2
[wkhtmltopdf_executable]
recipe = collective.recipe.cmd
on_install = true
on_update = true
cmds =
cd ${buildout:directory}/parts/wkhtmltopdf
mv wkhtmltopdf-amd64 wkhtmltopdf
chmod +x wkhtmltopdf
Can you please tell me what I did wrong?. Help will be deeply appreciated. Thank you
I'm the main developer of Send as PDF. One simple question: do you really need to use Pisa/report lab ?
I've added it at the beginning of the tool development but the support for this PDF generator will be dropped soon (wkhtmltopdf works like a charm and it's a bit hard to maintain both supports).
If you look at the product's README, there is explanations for installing WKHtmlToPDF: https://github.com/vincent-psarga/collective.sendaspdf
I strongly suggest you to use this tool, there's more options for it than what you would have with Pisa.
If you really need Pisa/reportlab, I'll take a look at the issue anyway ;)
Cheers,
Vincent
Looking over the source code I think you have hit a bug here.
The code expects the HTML being input to be a unicode string, but this is not the case for you, and re-encoding it to ASCII fails.
You'll need to file a bug report with your traceback in the collective.sendaspdf issue tracker on GitHub.

Resources