Yesterday I asked a question about using Excel and Python simultaneously. The solution was found: using
However, there is another problem connected with that – I can not save my
.py file as an executable file (
Here is the code I try to save:
import xlwings as xl import numpy import time wb = xl.Workbook.active() sheet = wb.active iter = input("How many iterations do you need? \n") i = 0 cell1 = raw_input("Write a column where you need to iterate \n") cell2 = int(raw_input("Write a row where you need to iterate \n")) while True: i += 1 if i <= iter: arg = numpy.random.uniform() xl.Range("%s%d" % (cell1, cell2)).value = arg else: break wb.save() print("Done!") time.sleep(2)
I tried to use
cx_freezer and made a
setup.py file with the following code:
from cx_Freeze import setup, Executable setup( name = "Uniform distribution generator", version = "1.0", description = "Uniform distribution generator", executables = [Executable("doiterations.py")] )
setyp.py files with the similar code properly worked with other modules. However, this time I got an error
no file named sys:
cx_Freeze.freezer.ConfigError: no file named sys (for module collections.sys)
I tried to use
PyInstaller package with the following command:
and again faced an error:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc0 in position 7: ordinal not in range(128)
I searched through Google and Stackoverflow and found some comments on this problem that may help to find the solution:
My version of Python is 2.7.
Please, help to solve the problem and create a working executable file!
At least in the case of cx_freeze an explanation can be found: https://bitbucket.org/anthony_tuininga/cx_freeze/issues/127/collectionssys-error
Unfortunately Python Package Index does not provide a version of cx_freeze that includes the necessary changes. A new version of cx_Freeze can be installed after Microsoft Visual C++ Compiler for Python 2.7 has been installed. It is possible to install python packages from other locations than Python Package Index with pip command, in this case
pip install --upgrade https://bitbucket.org/anthony_tuininga/cx_freeze/get/tip.zip
This needs to be done in Anaconda prompt that should be found from the Start menu. command prompt suffices if the PATH has been modified during the installation of Anaconda.