I use last version pyinstaller, python 2.7.5, OSX
And when I try pack this code:
import Crypto.Cipher._AES as AES
import Crypto.Hash._SHA256 as SHA256
if __name__ == '__main__':
c = AES.new('1234567890123456')
cipher = c.encrypt('blabblabblabblab')
print(cipher.encode('hex'))
h = SHA256.new('blabblabblabblab')
print(h.hexdigest())
python pyinstaller.py /Users/alexey/secure_backup/cryptotest.py -F
It successful, but this output has occurs when I run program from console:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/alexey/Downloads/pyinstaller-develop/PyInstaller/loader/pyimod03_importers.py", line 382, in load_module
exec(bytecode, module.__dict__)
File "build/bdist.macosx-10.9-intel/egg/Crypto/Cipher/_AES.py", line 7, in <module>
File "build/bdist.macosx-10.9-intel/egg/Crypto/Cipher/_AES.py", line 6, in __bootstrap__
ImportError: dlopen(/var/folders/nd/1m2t9wmx4jv1gdw_h0s9sp3w0000gp/T/_MEI81X1du/Crypto/Cipher/_AES.so, 2): image not found
--hidden-import=Crypto.Cipher._AES also not work
Related
Hello I am trying to execute a python script in the Ubuntu subsystem I enabled in Windows.
The reason I want to do this is because I have scheduled with crontab to run this script daily.
The problem I have is that the same script that passes when I run on normal Windows terminal fails on the ubuntu terminal. I am executing with Pyhon3 in both cases.
The problem seems to be related to how I am processing the json data.
What the code does is to get the response an API call returns, add add its contents in an excel file with the help of the tablib library which I have installed.
call_api_call method returns the json in this form: return json.loads(response.text)
Related Part of Code:
dataset_list = call_api_call()
data = tablib.Dataset()
data.json = json.dumps(dataset_list)
data_export = data.export('xlsx')
filename = os.path.dirname(os.path.realpath(__file__)) + '_' + str(datetime.date.today()) + '.xlsx'
with open(filename, 'wb') as f:
f.write(data_export) # write issues to the xlsx file
Running from Windows on an Ubuntu terminal:
Execute with:
python3 /mnt/c/Users/marialena/source/repos/GitLab_Issues/gitlab.py -vs
Output:
Traceback (most recent call last):
File "/mnt/c/Users/marialena/source/repos/GitLab_Issues/gitlab.py", line 93, in <module>
data1 = json.loads(list_with_bugs)
File "/usr/lib/python3.6/json/__init__.py", line 348, in loads
'not {!r}'.format(s.__class__.__name__))
TypeError: the JSON object must be str, bytes or bytearray, not 'dict'
Running from Windows normal terminal:
Execute with:
PS C:\Users\marialena\source\repos\GitLab_Issues> python .\gitlab.py
Output:
No error, File gets created with no issue.
Update:
I have updated python from 3.6.8 to 3.7.3 in the unix subsystem using the following command to match the windows version (after i have installed again tablib with python3.7 -m pip install tablib)
python3.7 /mnt/c/Users/marialena/source/repos/GitLab_Issues/gitlab.py -vs
When I execute now the script I get
Traceback (most recent call last):
File "/mnt/c/Users/marialena/source/repos/GitLab_Issues/gitlab.py", line 93, in <module>
data.json = json.dumps(list_with_bugs)
File "/usr/local/lib/python3.7/dist-packages/tablib/formats/_json.py", line 39, in import_set
dset.dict = json.loads(in_stream)
File "/usr/local/lib/python3.7/dist-packages/tablib/core.py", line 381, in _set_dict
if isinstance(pickle[0], list):
KeyError: 0
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Original exception was:
Traceback (most recent call last):
File "/mnt/c/Users/marialena/source/repos/GitLab_Issues/gitlab.py", line 93, in <module>
data.json = json.dumps(list_with_bugs)
File "/usr/local/lib/python3.7/dist-packages/tablib/formats/_json.py", line 39, in import_set
dset.dict = json.loads(in_stream)
File "/usr/local/lib/python3.7/dist-packages/tablib/core.py", line 381, in _set_dict
if isinstance(pickle[0], list):
KeyError: 0
There is a ModuleNotFoundError at the traceback for apt_pkg.
You could try reinstalling that package, and checking if it works.
sudo apt-get remove --purge python-apt
sudo apt-get install python-apt
I am a complete newbie to Python.
I have downloaded and installed Anaconda 3.5.2 on Windows 7, then Eclipse Photon. Installed the PyDev Plugin.
I was able to run a few simple test programs in Eclipse.
Suddenly, without installing anything I get
Error processing line 1 of C:\Anaconda3\lib\site-packages\matplotlib-2.2.2-py3.6-nspkg.pth:
Failed to import the site module
Traceback (most recent call last):
File "C:\Anaconda3\lib\site.py", line 168, in addpackage
exec(line)
File "<string>", line 1, in <module>
File "C:\Anaconda3\lib\types.py", line 171, in <module>
import functools as _functools
File "C:\Anaconda3\lib\functools.py", line 21, in <module>
from collections import namedtuple
ImportError: cannot import name 'namedtuple'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Anaconda3\lib\site.py", line 541, in <module>
main()
File "C:\Anaconda3\lib\site.py", line 523, in main
known_paths = addsitepackages(known_paths)
File "C:\Anaconda3\lib\site.py", line 320, in addsitepackages
addsitedir(sitedir, known_paths)
File "C:\Anaconda3\lib\site.py", line 207, in addsitedir
addpackage(sitedir, name, known_paths)
File "C:\Anaconda3\lib\site.py", line 178, in addpackage
import traceback
File "C:\Anaconda3\lib\traceback.py", line 5, in <module>
import linecache
File "C:\Anaconda3\lib\linecache.py", line 8, in <module>
import functools
File "C:\Anaconda3\lib\functools.py", line 21, in <module>
from collections import namedtuple
ImportError: cannot import name 'namedtuple'
even with a "Hello World" which ran before
Any ideas what could cause this?
I have found the reason:
I have added a "PyDev Package" named "collections" in the IDE. This collided with something ....
You can try a few things. Have you tried updating the package in conda? It is possible it is not up to date. Also, with Eclipse (and with most IDEs) if things that were working a moment break without any changes it is a sign you should quit the program, give it a moment to settle, and try reopening and rerunning your code. Sometimes it is the tool's fault!
I am using python version 3.6.1 and my operating system is Windows 10
My code is not working and I am getting the following error:
Traceback (most recent call last): File "<pyshell#2>", line 1, in
<module>
import pythoncom File "C:\Users\Egypt\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pythoncom.py",
line 2, in <module>
import pywintypes File "C:\Users\Egypt\AppData\Local\Programs\Python\Python36-32\lib\site-packages\win32\lib\pywintypes.py",
line 127, in <module>
__import_pywin32_system_module__("pywintypes", globals()) File "C:\Users\Egypt\AppData\Local\Programs\Python\Python36-32\lib\site-packages\win32\lib\pywintypes.py",
line 114, in __import_pywin32_system_module__
mod = imp.load_dynamic(modname, found) File "C:\Users\Egypt\AppData\Local\Programs\Python\Python36-32\lib\imp.py",
line 342, in load_dynamic
return _load(spec)
TypeError: bad argument type for built-in operation
Please help me to Complete my first script.
I'm new to Linux and generally installing packages via command line syntax.
I've tried installing numba (to use jit) into Python and this is the error I receive.I did this originally with GitHub source, and again with Anaconda. Numba appear to be installed correctly in the command line, however when I try to import into Spyder I get the below error
llvmlite imports without error.
>>> import numba
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/numba-0.22.1_13.g1902d7f-py2.7-linux-x86_64.egg/numba/__init__.py", line 7, in <module>
from . import testing, decorators
File "/usr/local/lib/python2.7/dist-packages/numba-0.22.1_13.g1902d7f-py2.7-linux-x86_64.egg/numba/testing.py", line 6, in <module>
from numba import config
File "/usr/local/lib/python2.7/dist-packages/numba-0.22.1_13.g1902d7f-py2.7-linux-x86_64.egg/numba/config.py", line 9, in <module>
import llvmlite.binding as ll
File "/usr/local/lib/python2.7/dist-packages/llvmlite-0.0.0-py2.7.egg/llvmlite/binding/__init__.py", line 6, in <module>
from .dylib import *
File "/usr/local/lib/python2.7/dist-packages/llvmlite-0.0.0-py2.7.egg/llvmlite/binding/dylib.py", line 4, in <module>
from . import ffi
File "/usr/local/lib/python2.7/dist-packages/llvmlite-0.0.0-py2.7.egg/llvmlite/binding/ffi.py", line 43, in <module>
lib = ctypes.CDLL(_lib_name)
File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libllvmlite.so: cannot open shared object file: No such file or directory
In my script I have imported lxml module. I made an executable file from my script using pyinstaller on Ubuntu. When I run the executable file in terminal I get the following error:
Traceback (most recent call last):
File "<string>", line 15, in <module>
File "/home/yaa110/workspace/Python27/src/PyInstaller-2.1/PyInstaller/loader/pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "/home/yaa110/workspace/Python27/src/PyInstaller-2.1/process/build/process/out00-PYZ.pyz/lxml.html", line 42, in <module>
ImportError: cannot import name etree
How can I fix it?
I'm using Python 2.7.5 on Ubuntu