You're welcome. Thanks for providing a test case. I'll look into why this is happening and get back to you.
Anthony On Fri, Nov 18, 2016 at 10:50 AM, Richie Ward <rich...@gmail.com> wrote: > Thanks, an absolute path seems to cure it. I don't know if there's any > other fixes or workarounds. > > I have attached a test case, it works fine during normal python > execution but when cx_freezed and not ran with a absolute path, it > crashes. > > Another hack is to copy ./lib to the directory that I used os.chdir on. > > To use the test case: > 1) Make a directory called future_import in your home directory > 2) Put future_import.py in there. > 3) Edit run_crash.py so that the path to the directory matches. > 4) Just run usual python3 freeze_setup.py build > 5) Run with ./run_crash > > Normal output: > r@r-H61N-USB3:~/Code/cx_freeze_bug$ ./run_crash.py > This will attempt to glitch cx_freeze... > /home/r/future_import > <module 'future_import' from '/home/r/future_import/future_import.py'> > Loaded __future__ > _Feature((2, 5, 0, 'alpha', 1), (3, 0, 0, 'alpha', 0), 16384) > Program ran ok. > r@r-H61N-USB3:~/Code/cx_freeze_bug$ > > Bug output: > r@r-H61N-USB3:~/Code/cx_freeze/build/exe.linux-x86_64-3.5$ ./run_crash > This will attempt to glitch cx_freeze... > /home/r/future_import > Traceback (most recent call last): > File "<frozen importlib._bootstrap>", line 969, in _find_and_load > File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked > File "<frozen importlib._bootstrap>", line 664, in _load_unlocked > File "<frozen importlib._bootstrap>", line 634, in > _load_backward_compatible > File "/usr/local/lib/python3.5/dist-packages/cx_Freeze/ > initscripts/__startup__.py", > line 12, in <module> > __import__(name + "__init__") > File "<frozen importlib._bootstrap>", line 969, in _find_and_load > File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked > File "<frozen importlib._bootstrap>", line 664, in _load_unlocked > File "<frozen importlib._bootstrap>", line 634, in > _load_backward_compatible > File "/usr/local/lib/python3.5/dist-packages/cx_Freeze/ > initscripts/Console.py", > line 21, in <module> > scriptModule = __import__(moduleName) > File "<frozen importlib._bootstrap>", line 969, in _find_and_load > File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked > File "<frozen importlib._bootstrap>", line 664, in _load_unlocked > File "<frozen importlib._bootstrap>", line 634, in > _load_backward_compatible > File "run_crash.py", line 17, in <module> > File "run_crash.py", line 12, in main > File "/home/r/future_import/future_import.py", line 1, in <module> > from __future__ import absolute_import > File "<frozen importlib._bootstrap>", line 969, in _find_and_load > File "<frozen importlib._bootstrap>", line 954, in _find_and_load_unlocked > File "<frozen importlib._bootstrap>", line 896, in _find_spec > File "<frozen importlib._bootstrap_external>", line 1147, in find_spec > File "<frozen importlib._bootstrap_external>", line 1123, in _get_spec > File "<frozen importlib._bootstrap_external>", line 1104, in > _legacy_get_spec > File "<frozen importlib._bootstrap>", line 444, in spec_from_loader > File "<frozen importlib._bootstrap_external>", line 541, in > spec_from_file_location > FileNotFoundError: [Errno 2] No such file or directory: > './lib/python35.zip' > r@r-H61N-USB3:~/Code/cx_freeze/build/exe.linux-x86_64-3.5$ > > On 18 November 2016 at 15:13, Anthony Tuininga > <anthony.tuini...@gmail.com> wrote: > > Can you provide a test case that demonstrates this? I can take a look, > then. > > In theory this is happening fairly early in the execution of your > program so > > it should be reasonably easy to replicate. > > > > Just out of curiosity, what happens if you use an absolute path when > running > > your application? > > > > Anthony > > > > On Fri, Nov 18, 2016 at 5:43 AM, Richie Ward <rich...@gmail.com> wrote: > >> > >> I need to tell cx_freeze the full path of ./lib/python35.zip as my app > >> requires changing the current directory. I am using os.chdir to change > >> directory. > >> > >> Due to the design of my program, I cannot change it back in time to > >> prevent the traceback as it runs foreign code. I tried adding the lib > >> folder to sys.path but cx_freeze still doesn't find its required > >> python35.zip file. > >> > >> I get the following traceback on my program: > >> r@r-H61N-USB3:~/Code/hypernucleus/hn$ ./run_hypernucleus -r > kitten_command > >> /home/r/Code/hypernucleus/hn/lib/python35.zip > >> Traceback (most recent call last): > >> File "<frozen importlib._bootstrap>", line 969, in _find_and_load > >> File "<frozen importlib._bootstrap>", line 958, in > >> _find_and_load_unlocked > >> File "<frozen importlib._bootstrap>", line 664, in _load_unlocked > >> File "<frozen importlib._bootstrap>", line 634, in > >> _load_backward_compatible > >> File > >> "/usr/local/lib/python3.5/dist-packages/cx_Freeze-5.0- > py3.5-linux-x86_64.egg/cx_Freeze/initscripts/__startup__.py", > >> line 12, in <module> > >> __import__(name + "__init__") > >> File "<frozen importlib._bootstrap>", line 969, in _find_and_load > >> File "<frozen importlib._bootstrap>", line 958, in > >> _find_and_load_unlocked > >> File "<frozen importlib._bootstrap>", line 664, in _load_unlocked > >> File "<frozen importlib._bootstrap>", line 634, in > >> _load_backward_compatible > >> File > >> "/usr/local/lib/python3.5/dist-packages/cx_Freeze-5.0- > py3.5-linux-x86_64.egg/cx_Freeze/initscripts/Console.py", > >> line 21, in <module> > >> scriptModule = __import__(moduleName) > >> File "<frozen importlib._bootstrap>", line 969, in _find_and_load > >> File "<frozen importlib._bootstrap>", line 958, in > >> _find_and_load_unlocked > >> File "<frozen importlib._bootstrap>", line 664, in _load_unlocked > >> File "<frozen importlib._bootstrap>", line 634, in > >> _load_backward_compatible > >> File "run_hypernucleus.py", line 3, in <module> > >> File "/home/r/Code/hypernucleus/hypernucleus/__init__.py", line 45, in > >> main > >> game_mgr.execute_game(args.run_game) > >> File "/home/r/Code/hypernucleus/hypernucleus/library/game_manager.py", > >> line 62, in execute_game > >> game = __import__(game_name) > >> File > >> "/home/r/.config/hypernucleus/games/kitten_command/kitten_command.py", > >> line 19, in <module> > >> from __future__ import division > >> File "<frozen importlib._bootstrap>", line 969, in _find_and_load > >> File "<frozen importlib._bootstrap>", line 954, in > >> _find_and_load_unlocked > >> File "<frozen importlib._bootstrap>", line 896, in _find_spec > >> File "<frozen importlib._bootstrap_external>", line 1147, in find_spec > >> File "<frozen importlib._bootstrap_external>", line 1123, in _get_spec > >> File "<frozen importlib._bootstrap_external>", line 1104, in > >> _legacy_get_spec > >> File "<frozen importlib._bootstrap>", line 444, in spec_from_loader > >> File "<frozen importlib._bootstrap_external>", line 541, in > >> spec_from_file_location > >> FileNotFoundError: [Errno 2] No such file or directory: > >> './lib/python35.zip' > >> > >> Any idea on how to fix this? I need to force it to use a absolute path > >> or make it look in sys.path for it (or something similar). I am using > >> cx_freeze 5.0 and Ubuntu Linux. > >> > >> -- > >> Thanks, Richie Ward > >> https://uk.linkedin.com/in/richie-ward-07ab0495 > >> > >> > >> ------------------------------------------------------------ > ------------------ > >> _______________________________________________ > >> cx-freeze-users mailing list > >> cx-freeze-users@lists.sourceforge.net > >> https://lists.sourceforge.net/lists/listinfo/cx-freeze-users > > > > > > > > ------------------------------------------------------------ > ------------------ > > > > _______________________________________________ > > cx-freeze-users mailing list > > cx-freeze-users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/cx-freeze-users > > > > > > -- > Thanks, Richie Ward > https://uk.linkedin.com/in/richie-ward-07ab0495 > > ------------------------------------------------------------ > ------------------ > > _______________________________________________ > cx-freeze-users mailing list > cx-freeze-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/cx-freeze-users > >
------------------------------------------------------------------------------
_______________________________________________ cx-freeze-users mailing list cx-freeze-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/cx-freeze-users