I'm working on a python program which reads parquet type file and converts it in to pandas dataframe. It works fine while i use the python command to run it (python framework1.py arg1 arg2). But after converting it to an executable file using pyinstaller and when the executable file is ran , it gives the following error.
Traceback (most recent call last):
File "framework1.py", line 325, in <module>
File "filetype.py", line 24, in fileTypeSelector
File "pandas/io/parquet.py", line 256, in read_parquet
File "pandas/io/parquet.py", line 38, in get_engine
File "pandas/io/parquet.py", line 89, in __init__
File "distutils/version.py", line 296, in __cmp__
AttributeError: LooseVersion instance has no attribute 'version'
[17249] Failed to execute script framework1
Thanks in advance :)
I solved the issue by using fastparquet engine rather than using pyarrow.
df1=pd.read_parquet(filepath,engine='fastparquet')
Related
I saved python script in single executable file with Pyinstaller, but when I tried to run it in console ./dist/myscript/myscript it raise AttributeError error with log below.
Log info
Traceback (most recent call last):
File "service.py", line 75, in <module>
File "service.py", line 31, in job
File "modelInstance.py", line 20, in __init__
File "prophet/forecaster.py", line 141, in __init__
File "prophet/forecaster.py", line 154, in _load_stan_backend
AttributeError: 'Prophet' object has no attribute 'stan_backend'
[1413] Failed to execute script 'service' due to unhandled exception!
As you see I'm using facebook's Prophet library to forecast time series data and all done in docker the container.
I am using Pyinstaller to compile Python to a standalone executable. The sourcecode includes modules PySide and SqlAlchemy. The dist .exe that PyInstaller creates runs OK, but when I run commands that access the database I get this error code in the command prompt:
Traceback (most recent call last):
File "clipper_tree.py", line 1907, in add_tree
File "build\bdist.win-amd64\egg\sqlalchemy\sql\operators.py", line 304, in __eq__
File "build\bdist.win-amd64\egg\sqlalchemy\orm\attributes.py", line 175, in operate
File "build\bdist.win-amd64\egg\sqlalchemy\sql\operators.py", line 304, in __eq__
File "build\bdist.win-amd64\egg\sqlalchemy\orm\properties.py", line 270, in operate
File "build\bdist.win-amd64\egg\sqlalchemy\sql\annotation.py", line 95, in __eq__
File "build\bdist.win-amd64\egg\sqlalchemy\sql\operators.py", line 304, in __eq__
File "build\bdist.win-amd64\egg\sqlalchemy\sql\elements.py", line 686, in operate
File "build\bdist.win-amd64\egg\sqlalchemy\sql\operators.py", line 304, in __eq__
File "<string>", line 1, in <lambda>
File "build\bdist.win-amd64\egg\sqlalchemy\sql\type_api.py", line 62, in operate
File "build\bdist.win-amd64\egg\sqlalchemy\util\langhelpers.py", line 964, in __getattr__
File "build\bdist.win-amd64\egg\sqlalchemy\util\langhelpers.py", line 962, in __getattr__
ImportError: Could not resolve module sqlalchemy.sql.default_comparator
While compiling, the command prompt output a few warnings about not being able to find "hidden DLLs" relating to sql alchemy. It said it was removing sqlalchemy/test files in response. Any help here would be deeply appreciated.
i had a same issue earlier.. resolves this problem by importing sqlalchemy.sql.default_comparator on my main program..
As #fredpi says you can add the module to the hiddenimports parameter of the Analysis initializer in the .spec file of the python file your trying to compile. Like so: hiddenimports=['sqlalchemy.sql.default_comparator']
Make sure you pass the .spec file when you run pyinstaller, or it will overwrite the .spec file and your changes will be lost. For example: pyinstaller --onefile myscript.spec
I am fairly new to Python and I need some help with an error message I am receiving. I am trying to make an exe file from a tkinter script with the help of py2exe, but I keep getting an AssertionError whenever I try to run the setup.py script. I have already created an exe file on my computer only a couple of days ago out of the same script without using tkinter. Creating this exe file was no problem. I am wondering if the error message occurs due to the fact that I have already created an exe file recently.
My setup.py script looks normal:
`# setup.py
from distutils.core import setup
import py2exe
setup(console=['MyScript.py'])`
Whenever I run it, I get this error:
AssertionError: distutils has already been patched by <class 'py2exe.patch_distutils.patch_distutils.<locals>.Distribution'>
The entire traceback looks like this:
Traceback (most recent call last):
File "C:\Dir\JetBrains\PyCharm Community Edition 2016.2.3\helpers\pycharm\pycharm_setup_runner.py", line 26, in <module>
exec (fh.read(), globals(), locals())
File "<string>", line 6, in <module>
File "C:\Dir\Python3\lib\distutils\core.py", line 134, in setup
ok = dist.parse_command_line()
File "C:\Dir\Python3\lib\distutils\dist.py", line 471, in parse_command_line
args = self._parse_command_opts(parser, args)
File "C:\Dir\Python3\lib\distutils\dist.py", line 527, in _parse_command_opts
cmd_class = self.get_command_class(command)
File "C:\Dir\Python3\lib\distutils\dist.py", line 817, in get_command_class
__import__ (module_name)
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.2.3\helpers\pycharm\pycharm_commands\pycharm_test.py", line 4, in <module>
from setuptools.command import test
File "C:\Dir\Python3\lib\site-packages\setuptools\__init__.py", line 14, in <module>
from setuptools.extension import Extension
File "C:\Dir\Python3\lib\site-packages\setuptools\extension.py", line 10, in <module>
from .dist import _get_unpatched
File "C:\Dir\Python3\lib\site-packages\setuptools\dist.py", line 39, in <module>
_Distribution = _get_unpatched(_Distribution)
File "C:\Dir\Python3\lib\site-packages\setuptools\dist.py", line 35, in _get_unpatched
"distutils has already been patched by %r" % cls
AssertionError: distutils has already been patched by <class'py2exe.patch_distutils.patch_distutils.<locals>.Distribution'>
Does anyone know a workaround to this problem? I am working in Python3.4.1.
Thank you so much for helping!
Try importing setuptools before you import py2exe.
It worked for me.
I've frozen my app with cx_Freeze and when running the .exe I get this error (only error):
C:\Python34\build\exe.win32-3.4>run.exe
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27
, in <module>
exec(code, m.__dict__)
File "run.py", line 18, in <module>
File "C:\Python34\Socket.py", line 5, in openSocket
s = socket.socket()
TypeError: 'module' object is not callable
If I run my app in Python then it works perfectly fine.I have done import socket in both the main python file (run.py) and the one mentioned in the error above (Socket.py)
How do I fix this?
Try renaming your "Socket.py" file to something else ("socket_maker.py"). Then delete all *.pyc files from the current directory (especially anything called socket.pyc).
I'm thinking that the module name you are trying to import is conflicting with the object and function names.
I have been using AWS CLI on Ubuntu for a month. But today AWS CLI is throwing a python error, I haven't seen before:
sashank#sashank:~$ aws configure
Traceback (most recent call last):
File "/usr/local/bin/aws", line 27, in <module>
sys.exit(main())
File "/usr/local/bin/aws", line 23, in main
return awscli.clidriver.main()
File "/usr/local/lib/python2.7/dist-packages/awscli/clidriver.py", line 48, in main
return driver.main()
File "/usr/local/lib/python2.7/dist-packages/awscli/clidriver.py", line 173, in main
parser = self._create_parser()
File "/usr/local/lib/python2.7/dist-packages/awscli/clidriver.py", line 154, in _create_parser
command_table['help'] = self.create_help_command()
File "/usr/local/lib/python2.7/dist-packages/awscli/clidriver.py", line 149, in create_help_command
cli_data.get('help_usage', None))
File "/usr/local/lib/python2.7/dist-packages/awscli/help.py", line 259, in __init__
HelpCommand.__init__(self, session, session.provider,
AttributeError: 'Session' object has no attribute 'provider'
I have tried purging AWS CLI and removing all package files and re-installing, but error persists. Plz help!! Thanks.
Probably you have upgraded your virtualenv/setuptools and now your utility is screwed up. It happened to me with a wrongly set Chef that upgraded those two packages and, after that, the utility stopped working.