It gives me the error only after I have converted it to an exe, works fine as a .py file
I tried to find the file missing and replace it but it still didn't work.
The error I get is:
Traceback (most recent call last):
File "tkinter_init_.py", line 1705, in call
File "CompilerGui.py", line 259, in
done = ttk.Button(window, text="Compile", command=lambda:finish(texts,
window, search_folder))
File "CompilerGui.py", line 210, in finish cb.the_main(q_list, values)
File "CompilerBase.py", line 323, in the_main
file_written = write_docx(values_dict, file_to_write)
File "CompilerBase.py", line 100, in write_docx
my_docx = docx.Document()
File "site-packages\docx\api.py", line 25, in Document
File "site-packages\docx\opc\package.py", line 128, in open
File "site-packages\docx\opc\pkgreader.py", line 32, in from_file
File "site-packages\docx\opc\phys_pkg.py", line 31, in new
docx.opc.exceptions.PackageNotFoundError: Package not found at
'C:\Users\LENOVO\AppData\Local\Temp_MEI92522\docx\templates\default.docx'
In your .spec file, I think you can add:
datas= [ ('C:\\Program Files\\Python36\\Lib\\site-packages\\docx\\templates\\*', 'docx\\templates' ) ],
in the Analysis section, to add the missing file to your exe. This, of course, assumes that the missing default.docx is in the specified folder.
I figured out the solution to the problem, it was looking for a folder that didn't exist. Here's how I fixed it : https://youtu.be/bB9RXak4eVY
Another fairly simple fix would be to just copy the default.docx into your app directory, change my_docx = docx.Document() to my_docx = docx.Document(docx='default.docx'), and add datas=[('default.docx', '.')] to your .spec file.
Related
I just installed the streamlit package. When I try to run 'streamlit hello' I get the following error:
(base) C:\>streamlit hello Traceback (most recent call last):
File "c:\users\s158539\appdata\local\continuum\anaconda3\lib\runpy.py",
line 193, in _run_module_as_main "__main__", mod_spec)
File "c:\users\s158539\appdata\local\continuum\anaconda3\lib\runpy.py",
line 85, in _run_code exec(code, run_globals)
File "C:\Users\s158539\AppData\Local\Continuum\anaconda3\Scripts\streamlit.exe\__main__.py",
line 5, in <module>
File "c:\users\s158539\appdata\local\continuum\anaconda3\lib\site-packages\streamlit\__init__.py",
line 121, in <module> from streamlit.DeltaGenerator import DeltaGenerator as _DeltaGenerator
File "c:\users\s158539\appdata\local\continuum\anaconda3\lib\site-packages\streamlit\DeltaGenerator.py",
line 33, in <module> from streamlit import caching
File "c:\users\s158539\appdata\local\continuum\anaconda3\lib\site-packages\streamlit\caching.py",
line 38, in <module> from streamlit.hashing import CodeHasher
File "c:\users\s158539\appdata\local\continuum\anaconda3\lib\site-packages\streamlit\hashing.py",
line 36, in <module> from streamlit.folder_black_list import FolderBlackList
File "c:\users\s158539\appdata\local\continuum\anaconda3\lib\site-packages\streamlit\folder_black_list.py",
line 39, in <module> if config.get_option("global.developmentMode"):
File "c:\users\s158539\appdata\local\continuum\anaconda3\lib\site-packages\streamlit\config.py",
line 94, in get_option parse_config_file()
File "c:\users\s158539\appdata\local\continuum\anaconda3\lib\site-packages\streamlit\config.py",
line 877, in parse_config_file _update_config_with_toml(file_contents, filename)
File "c:\users\s158539\appdata\local\continuum\anaconda3\lib\site-packages\streamlit\config.py",
line 799, in _update_config_with_toml parsed_config_file = toml.loads(raw_toml)
File "c:\users\s158539\appdata\local\continuum\anaconda3\lib\site-packages\toml\decoder.py",
line 379, in loads original, pos) toml.decoder.TomlDecodeError: Key group not on a line by itself. (line 1 column 1 char
Does anyone know how to solve this error?
Thank you in advance!
Just delete the config.toml file which can be found in the directory where you have installed streamlit.
I also got the same error while I tried to run the 'streamlit' command.
So, what I did is track in the code entirely to see from where I can find this 'config.toml' and simply deleted the file.
The path for 'config.toml' file in Windows is: C:users/{username}/.streamlit/config.toml
Delete this file and it will solve the error.
If you are not able to locate your .streamlit directory
Run streamlit cache clear
Output :
Nothing to clear at {Username}\{path}\.streamlit\cache.
You will get output similar to this which will tell you where is your .streamlit directory exactly.
Take this path before the cache part
cd {Username}\{path}\.streamlit
You'll be able to see config.toml here just delete that file.
The Streamlit forum has this discussion topic: https://discuss.streamlit.io/t/toml-docoder-error/1400/10 that discusses this. Hope this helps!
delete the content of config.toml file which is
in C:\Users\username.streamlit
Do you have a setup.sh file? What's the content inside it?
maybe you will just have to put the content of setup.sh everything in 1 line like this
[server]\nheadless = true\nenableCORS=false\nport = \n
my problem was similar, not exactly like this. so I hope it works!
I am trying to run this tensorflow example: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/skflow/text_classification_character_cnn.py
However it keeps failing at the stage to open the tar file. This is the error message I am getting:
Successfully downloaded dbpedia_csv.tar.gz 1613 bytes.
Traceback (most recent call last):
File "text_classification_character_cnn.py", line 110, in <module>
tf.app.run()
File "/Users/alechewitt/Envs/solar_detection/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 30, in run
sys.exit(main(sys.argv))
File "text_classification_character_cnn.py", line 87, in main
'dbpedia', test_with_fake_data=FLAGS.test_with_fake_data, size='large')
File "/Users/alechewitt/Envs/solar_detection/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/datasets/__init__.py", line 64, in load_dataset
return DATASETS[name](size, test_with_fake_data)
File "/Users/alechewitt/Envs/solar_detection/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/datasets/text_datasets.py", line 48, in load_dbpedia
maybe_download_dbpedia(data_dir)
File "/Users/alechewitt/Envs/solar_detection/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/datasets/text_datasets.py", line 40, in maybe_download_dbpedia
tfile = tarfile.open(archive_path, 'r:*')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tarfile.py", line 1672, in open
raise ReadError("file could not be opened successfully")
tarfile.ReadError: file could not be opened successfully
Any help would be much appreciated
When you get that error, you can look at the downloaded dbpedia_dsv.tar.gz in a text editor, and you might find that it is actually a 404 webpage. The file you want seems to be available here as well (I found this link here):
https://drive.google.com/drive/folders/0Bz8a_Dbh9Qhbfll6bVpmNUtUcFdjYmF2SEpmZUZUcVNiMUw1TWN6RDV3a0JHT3kxLVhVR2M
Download that file (at your own risk) and replace it manually. Then you can run your script again.
Open the tar file using the full path. BTW the link you gave is 404 not found.
I have a simple program that takes input from the user and then does scraping with selenium. Since the user doesn't have Python environment installed I would like to convert it to *.exe. I usually use cx_freeze for that and I have successfully converted .py programs to .exe. At first it was missing some modules (like lxml) but I was able to solve it. Now I think I only have problem with docx package.
This is how I initiate the new document in my program (I guess this is what causes me problems):
doc = Document()
#then I do some stuff to it and add paragraph and in the end...
doc.save('results.docx')
When I run it from python everything works fine but when I convert to exe I get this error:
Traceback (most recent call last):
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
exec(code, m.__dict__)
File "tribunalRio.py", line 30, in <module>
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\docx\api.py", line 25, in Document
document_part = Package.open(docx).main_document_part
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\docx\opc\package.py", line 116, in open
pkg_reader = PackageReader.from_file(pkg_file)
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\docx\opc\pkgreader.py", line 32, in from_file
phys_reader = PhysPkgReader(pkg_file)
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\docx\opc\phys_pkg.py", line 31, in __new__
"Package not found at '%s'" % pkg_file
docx.opc.exceptions.PackageNotFoundError: Package not found at 'C:\Users\tyszkap\Dropbox (Dow Jones)\Python Projects\build\exe.win-a
md64-3.4\library.zip\docx\templates\default.docx'
This is my setup.py program:
from cx_Freeze import setup, Executable
executable = Executable( script = "tribunalRio.py" )
# Add certificate to the build
options = {
"build_exe": {'include_files' : ['default.docx'],
'packages' : ["lxml._elementpath", "inspect", "docx", "selenium"]
}
}
setup(
version = "0",
requires = [],
options = options,
executables = [executable])
I thought that explicitly adding default.docx to the package would solve the problem (I have even tried adding it to the library.zip but it gives me even more errors) but it didn't. I have seen this post but I don't know what they mean by:
copying the docx document.py module inside my function (instead of
using Document()
Any ideas? I know that freezing is not the best solution but I really don't want to build a web interface for such a simple program...
EDIT:
I have just tried this solution :
def find_data_file(filename):
if getattr(sys, 'frozen', False):
# The application is frozen
datadir = os.path.dirname(sys.executable)
else:
# The application is not frozen
# Change this bit to match where you store your data files:
datadir = os.path.dirname(__file__)
return os.path.join(datadir, filename)
doc = Document(find_data_file('default.docx'))
but again receive Traceback error (but the file is in this location...):
Traceback (most recent call last):
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
exec(code, m.__dict__)
File "tribunalRio.py", line 43, in <module>
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\docx\api.py", line 25, in Document
document_part = Package.open(docx).main_document_part
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\docx\opc\package.py", line 116, in open
pkg_reader = PackageReader.from_file(pkg_file)
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\docx\opc\pkgreader.py", line 32, in from_file
phys_reader = PhysPkgReader(pkg_file)
File "C:\Users\tyszkap\AppData\Local\Continuum\Anaconda3\lib\site-packages\docx\opc\phys_pkg.py", line 31, in __new__
"Package not found at '%s'" % pkg_file
docx.opc.exceptions.PackageNotFoundError: Package not found at 'C:\Users\tyszkap\Dropbox (Dow Jones)\Python Projects\build\exe.win-a
md64-3.4\default.docx'
What am I doing wrong?
I expect you'll find the problem has to do with your freezing operation not placing the default Document() template in the expected location. It's stored as package data in the python-docx package as docx/templates/default.docx (see setup.py here: https://github.com/python-openxml/python-docx/blob/master/setup.py#L37)
I don't know how to fix that in your case, but that's where the problem is it looks like.
I had the same problem and managed to get around it by doing the following. First, I located the default.docx file in the site-packages. Then, I copied it in the same directory as my .py file. I also start the .docx file with Document() which has a docx=... flag, to which I assigned the value: os.path.join(os.getcwd(), 'default.docx') and now it looks like doc = Document(docx=os.path.join(os.getcwd(), 'default.docx')). The final step was to include the file in the freezing process. Et voilĂ ! So far I have no problem.
I've just installed pychecker on windows 7 Pro using "python setup.py install". When I run it on my script using the command:
c:\Python26\Scripts\pychecker -#100 finaltest17.py
I get the following error/traceback:
C:\Users\....\ToBeReleased>C:\Python26\python.exe C:\Python26\Lib\site-packages\pychecker\checker.py -#100 finaltest17.py
Processing module finaltest17 (finaltest17.py)...
Caught exception importing module finaltest17:
File "C:\Python26\Lib\site-packages\pychecker\pcmodules.py", line 533, in setupMainCode()
self.moduleName, self.moduleDir)
File "C:\Python26\Lib\site-packages\pychecker\pychecker\utils.py", line 184, in findModule()
handle, filename, smt = _q_find_module(p, path)
File "C:\Python26\Lib\site-packages\pychecker\pychecker\utils.py", line 162, in _q_find_module()
if not cfg().quixote:
File "C:\Python26\Lib\site-packages\pychecker\pychecker\utils.py", line 39, in cfg()
return _cfg[-1]
IndexError: list index out of range
Traceback (most recent call last):
File "C:\Python26\Lib\site-packages\pychecker\checker.py", line 364, in <module>
sys.exit(main(sys.argv))
File "C:\Python26\Lib\site-packages\pychecker\checker.py", line 337, in main
importWarnings = processFiles(files, _cfg, _print_processing)
File "C:\Python26\Lib\site-packages\pychecker\checker.py", line 270, in processFiles
loaded = pcmodule.load()
File "C:\Python26\Lib\site-packages\pychecker\pcmodules.py", line 477, in load
return utils.cfg().ignoreImportErrors
File "C:\Python26\Lib\site-packages\pychecker\pychecker\utils.py", line 39, in cfg
return _cfg[-1]
IndexError: list index out of range
If anyone could point me in the right direction that would be great.
Thanks
Stewart
Problem resolved.
I found the following support request on SourceForge which refers to a need to use short format (8.3) path and filenames in pychecker.bat and not long format as is allowed in newer versions of Windows.
https://sourceforge.net/p/pychecker/support-requests/7/#96cb
[2012-06-01 15:33:10,638][molisamples] ERROR:web-services:Uncaught exception
Traceback (most recent call last):
File "osv\osv.pyo", line 122, in wrapper
File "osv\osv.pyo", line 176, in execute
File "osv\osv.pyo", line 167, in execute_cr
File "C:\Program Files (x86)\OpenERP 6.0\Server\addons\base_report_designer\base_report_designer.py", line 42, in sxwtorml
File "C:\Program Files (x86)\OpenERP 6.0\Server\addons\base_report_designer\openerp_sxw2rml\openerp_sxw2rml.py", line 309, in sxw2rml
File "C:\Program Files (x86)\OpenERP 6.0\Server\addons\base_report_designer\openerp_sxw2rml\openerp_sxw2rml.py", line 294, in unpackNormalize
File "C:\Program Files (x86)\OpenERP 6.0\Server\addons\base_report_designer\openerp_sxw2rml\openerp_sxw2rml.py", line 269, in oo_read
File "zipfile.pyo", line 346, in init
File "zipfile.pyo", line 366, in _GetContents
File "zipfile.pyo", line 378, in _RealGetContents
BadZipfile: File is not a zip file
I get the above error when I try to convert a report I just designed to .rml (using Open Office Writer). Please what could be the issue. I am seriously confused here
You can convert your .sxw to .rml using base_report_designer module.
Try following steps:
Open terminal -> go to openerp_sxw2rml folder like this:
cd addons/base_report_designer/openerp_sxw2rml
Then run this command: python openerp_sxw2rml.py absolute path of sxw > absolute path of rml
Like this:
python openerp_sxw2rml.py /home/arya/my_module/report/my_report.sxw > /home/arya/my_module/report/my_report.rml
This will convert sxw file into rml and you can find your file at given path of rml.
Thank you.
The error says that the file is not a zip file, so it's probably expecting the compressed format of sxw file. Any chance you saved the file in OpenOffice's uncompressed format?
Make sure when you save in Openoffice Writer, you select the old format, the one with SXW extension.
Don't just type .sxw, make sure the program puts it there by itself by selecting the correct entry in the fileformat selectionbox (i forget the full title and cannot check atm)
I figured it out. I had some errors in the python parser file for the report. That's what was causing the issue. It's been fixed now. Thanks y'all for the help