I have been trying to figure out what the following error means but unfortunately I am not being able to handle it. The complete traceback resulting from the execution of the generated executable is:
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
File "/home/prog3/Ambiente/p34/lib/python3.4/site-packages/cx_Freeze-5.0.1-py3.4-linux-x86_64.egg/cx_Freeze/initscripts/__startup__.py", line 12, in <module>
__import__(name + "__init__")
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
File "/home/prog3/Ambiente/p34/lib/python3.4/site-packages/cx_Freeze-5.0.1-py3.4-linux-x86_64.egg/cx_Freeze/initscripts/Console.py", line 24, in <module>
exec(code, m.__dict__)
File "App.py", line 10, in <module>
File "/home/prog3/Ambiente/p34/lib/python3.4/site-packages/glymur/__init__.py", line 4, in <module>
from glymur import version
File "/home/prog3/Ambiente/p34/lib/python3.4/site-packages/glymur/version.py", line 15, in <module>
from distutils.version import LooseVersion
File "/home/prog3/Ambiente/p34/lib/python3.4/distutils/__init__.py", line 17, in <module>
real_distutils = imp.load_module("_virtualenv_distutils", None, distutils_path, ('', '', imp.PKG_DIRECTORY))
File "/home/prog3/Ambiente/p34/lib/python3.4/imp.py", line 245, in load_module
return load_package(name, filename)
File "/home/prog3/Ambiente/p34/lib/python3.4/imp.py", line 217, in load_package
return methods.load()
File "<frozen importlib._bootstrap>", line 1219, in load
AttributeError: 'NoneType' object has no attribute 'name'
My setup.py file looks like:
import sys
from cx_Freeze import setup,Executable
includefiles = ['libopenjp2.so','libopenjp2.so.2.2.0','libopenjp2.so.7']
includes = []
excludes = ['Tkinter']
packages = ["os","sys","PyQt5.QtCore","PyQt5.QtGui","PyQt5.QtWidgets","numpy", "subprocess","encodings","glymur","matplotlib","math","PIL","skimage","scipy","matplotlib.backends.backend_qt5agg","lxml","ctypes","re","collections","struct","contextlib","itertools","uuid","warnings"]
build_exe_options = {"packages":[],
"excludes":["Tkinter"],"includefiles":['libopenjp2.so','libopenjp2.so.2.2.0','libopenjp2.so.7'],"includes":[],"copy_dependent_files":True
}
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup(name='alignosis',
version='0.1',
description='Alignment of two differently stained whole-slide JPEG2000 digital pathology images',
options = {'build_exe': {'includes':includes,'excludes':excludes,'packages':packages,'include_files':includefiles}},
executables= [Executable('App.py')])
I must say that once my virtualenv containing all the required packages is activated and after execution of the above setup.py by: python setup.py build, I get no errors and so it is created the build folder.
I am aware that probably I dont need to have a so big list of packages to include given that some of them are built-in and I am sorry for that...
I appreciate any suggestion/help that you can give to me.
Thank you
Related
ide Pycharm. Google SDK installed lastest. What the problem? i used Python Interpreter 3.10 lastest. frozendict installed lastest, uplink installed, mapping installed
File "C:\Users\vgorbunov\AppData\Roaming\Python\Python310\site-packages\allure\pytest_plugin.py", line 9, in <module>
from allure.common import AllureImpl, StepContext
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "C:\Users\vgorbunov\AppData\Local\Programs\Python\Python310\lib\site-packages\_pytest\assertion\rewrite.py", line 168, in exec_module
exec(co, module.__dict__)
File "C:\Users\vgorbunov\AppData\Roaming\Python\Python310\site-packages\allure\common.py", line 19, in <module>
from allure.structure import Attach, TestStep, TestCase, TestSuite, Failure, Environment, EnvParameter
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "C:\Users\vgorbunov\AppData\Local\Programs\Python\Python310\lib\site-packages\_pytest\assertion\rewrite.py", line 168, in exec_module
exec(co, module.__dict__)
File "C:\Users\vgorbunov\AppData\Roaming\Python\Python310\site-packages\allure\structure.py", line 14, in <module>
class Attach(xmlfied('attachment',
File "C:\Users\vgorbunov\AppData\Roaming\Python\Python310\site-packages\allure\rules.py", line 116, in xmlfied
class MyImpl(namedlist('XMLFied', [(item[0], None) for item in items])):
File "C:\Users\vgorbunov\AppData\Roaming\Python\Python310\site-packages\namedlist.py", line 398, in namedlist
fields, defaults = _fields_and_defaults(typename, field_names, default, rename)
File "C:\Users\vgorbunov\AppData\Roaming\Python\Python310\site-packages\namedlist.py", line 252, in _fields_and_defaults
if isinstance(field_names, _collections.Collection):
AttributeError: module 'collections' has no attribute 'Mapping'
I am working in a docker environment where I have a spark cluster set up and I want to use shapely with pyspark.
I installed shapely with conda. In the spark-master I see:
MyEnv/lib/libgeos_c.so
MyEnv/lib/python3.7/site-packages/shapely
I zipped the whole site-packages folder and add this line to my notebook:
sc.addPyFile('/root/miniconda3/envs/spm_sim_unix_env/lib/python3.7/pack.zip')
but when I try to run this sample code:
sc.addPyFile('/root/miniconda3/envs/spm_sim_unix_env/lib/python3.7/pack.zip')
from shapely.geometry import Point
from pyspark.sql.functions import udf
from pyspark.sql.types import StringType
#udf(returnType=StringType())
def test():
pt = Point(32.7633,-96.90296)
return 'ok'
df = spark.createDataFrame([(1,2)],['c1','c2'])
df = df.withColumn('c3',test())
df
it returns the following error:
PythonException:
An exception was thrown from the Python worker. Please see the stack trace below.
Traceback (most recent call last):
File "/opt/spark/python/lib/pyspark.zip/pyspark/worker.py", line 589, in main
func, profiler, deserializer, serializer = read_udfs(pickleSer, infile, eval_type)
File "/opt/spark/python/lib/pyspark.zip/pyspark/worker.py", line 447, in read_udfs
udfs.append(read_single_udf(pickleSer, infile, eval_type, runner_conf, udf_index=i))
File "/opt/spark/python/lib/pyspark.zip/pyspark/worker.py", line 254, in read_single_udf
f, return_type = read_command(pickleSer, infile)
File "/opt/spark/python/lib/pyspark.zip/pyspark/worker.py", line 74, in read_command
command = serializer._read_with_length(file)
File "/opt/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 172, in _read_with_length
return self.loads(obj)
File "/opt/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 458, in loads
return pickle.loads(obj, encoding=encoding)
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
File "./pack.zip/shapely/geometry/__init__.py", line 4, in <module>
from .base import CAP_STYLE, JOIN_STYLE
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
File "./pack.zip/shapely/geometry/base.py", line 19, in <module>
from shapely.coords import CoordinateSequence
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
File "./pack.zip/shapely/coords.py", line 8, in <module>
from shapely.geos import lgeos
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
File "./pack.zip/shapely/geos.py", line 87, in <module>
_lgeos = load_dll('geos_c', fallbacks=alt_paths)
File "./pack.zip/shapely/geos.py", line 62, in load_dll
libname, fallbacks or []))
OSError: Could not find lib geos_c or load any of its variants ['libgeos_c.so.1', 'libgeos_c.so'].
I have tried the following:
zip the entire /lib folder and add this with addPyFiles instead of the site-packages folder: it says the worker cannot find the shapely module
set the os.environ['LD_LIBRARY_PATH'] = 'MyEnv/lib/' at the beginning of the script, nothing has changed.
Any suggestion?
Thanks in advance
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "D:\screener\screener\urls.py", line 15, in <module>
from userbase import views as user_views
File "D:\screener\userbase\views.py", line 26, in <module>
from .forms import (
File "D:\screener\userbase\forms.py", line 4, in <module>
from .import_companies import get_codes_from_file
File "D:\screener\userbase\import_companies.py", line 4, in <module>
from utilities.file_to_text import get_text
File "D:\screener\utilities\file_to_text.py", line 3, in <module>
import pdftotext
ImportError: DLL load failed: The specified module could not be found.
I installed folling https://coder.haus/2019/09/27/installing-pdftotext-through-pip-on-windows-10/ , and tried reinstalling using pip command, also tried it inside conda but all yielded the same result
I am unable to import pdftotext, any way to get it done?
I am using a python 3.4 environment in Anaconda 4.3, and I'm attempting to use py2exe to package a python script that uses selenium. The script runs perfectly as a .py file, but the .exe is returning an error when attempting to import the webdriver from the selenium module with the import statement:
from selenium import webdriver
This is the traceback returned in the console:
Traceback (most recent call last):
File "my_script.py", line 8, in <module>
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
File "C:\Users\me\.conda\envs\py34\lib\site-packages\selenium\webdriver\__init__.py", line 18, in <module>
from .firefox.webdriver import WebDriver as Firefox # noqa
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
File "C:\Users\me\.conda\envs\py34\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 40, in <module>
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
File "C:\Users\me\.conda\envs\py34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 25, in <module>
from .webelement import WebElement
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
File "C:\Users\me\.conda\envs\py34\lib\site-packages\selenium\webdriver\remote\webelement.py", line 40, in <module>
getAttribute_js = pkgutil.get_data(__package__, 'getAttribute.js').decode('utf8')
File "C:\Users\me\.conda\envs\py34\lib\pkgutil.py", line 611, in get_data
spec = importlib.util.find_spec(package)
File "C:\Users\me\.conda\envs\py34\lib\importlib\util.py", line 81, in find_spec
fullname = resolve_name(name, package) if name.startswith('.') else name
AttributeError: 'NoneType' object has no attribute 'startswith'
Edited to phrase this as an actual question: This import statement works fine when running the file as a .py script. Why would this only happen after being packaged by py2exe, and is there some kind of option I am missing in the py2exe setup file?
I'm trying to freeze a simple Python 3.4 script called test.py using pyinstaller. The script imports version 0.7.0 of the xlwings module (which I installed via pip), and then print a message.
import xlwings
print("Fine!")
If I remove the xlwings import, then pyinstaller test.py generates an EXE (I'm on Windows 10) inside the dist folder that prints the "Fine" message and then exits. But, if I import the xlwings module, the command generates an EXE that prints this message and then quits (not printing the "Fine" message):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.__dict__)
File "site-packages\xlwings\__init__.py", line 20, in <module>
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.__dict__)
File "site-packages\xlwings\_xlwindows.py", line 29, in <module>
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.__dict__)
File "site-packages\pandas\__init__.py", line 7, in <module>
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 573, in load_module
module = loader.load_module(fullname)
File "pandas\tslib.pyx", line 55, in init pandas.tslib (pandas\tslib.c:102924)
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1191, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1161, in _load_backward_compatible
File "C:\Python34\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.__dict__)
File "dateutil\zoneinfo\__init__.py", line 31, in <module>
File "dateutil\zoneinfo\__init__.py", line 24, in getzoneinfofile
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\OrangeFlash81\\AppData\\Local\\Temp\\_MEI102122\\dateutil\\zoneinfo'
test returned -1
I'm aware that cx_Freeze has issues when dateutil is imported, and this error message references dateutil. Does pyinstaller suffer the same issues, and if so, how can I resolve them?
It's not exactly a solution, but I decided to switch to using the XLRD module, which does everything I need and works flawlessly with pyinstaller; changing xlwings code to use XLRD isn't too difficult either.