cxfreeze script raises AttributionError: 'NoneType' object has no attribute 'startswith'

Issue #185 resolved
Mostafa Razavi
created an issue

I installed the latest version of cx_freeze (changeset 560:352d0dda3c77) in a clean virtualenv with Python 3.5.0+ (installed from Ubuntu 15.10 repositories; applied the workaround in this issue). I wrote a simple script:

#!/usr/bin/env python
print('hello', 'foo!')

Trying to run cxfreeze foo.py gives me this.

Traceback (most recent call last):
  File "./venv/bin/cxfreeze", line 4, in <module>
    __import__('pkg_resources').run_script('cx-Freeze==5.0', 'cxfreeze')
  File "/home/mostafa/source/foo/venv/lib/python3.5/site-packages/pkg_resources/__init__.py", line 735, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/home/mostafa/source/foo/venv/lib/python3.5/site-packages/pkg_resources/__init__.py", line 1652, in run_script
    exec(code, namespace, namespace)
  File "/home/mostafa/source/foo/venv/lib/python3.5/site-packages/cx_Freeze-5.0-py3.5-linux-x86_64.egg/EGG-INFO/scripts/cxfreeze", line 5, in
<module>
    main()
  File "/home/mostafa/source/foo/venv/lib/python3.5/site-packages/cx_Freeze-5.0-py3.5-linux-x86_64.egg/cx_Freeze/main.py", line 176, in main
    silent = options.silent)
  File "/home/mostafa/source/foo/venv/lib/python3.5/site-packages/cx_Freeze-5.0-py3.5-linux-x86_64.egg/cx_Freeze/freezer.py", line 144, in __i
nit__
    self._VerifyConfiguration()
  File "/home/mostafa/source/foo/venv/lib/python3.5/site-packages/cx_Freeze-5.0-py3.5-linux-x86_64.egg/cx_Freeze/freezer.py", line 451, in _Ve
rifyConfiguration
    executable._VerifyConfiguration(self)
  File "/home/mostafa/source/foo/venv/lib/python3.5/site-packages/cx_Freeze-5.0-py3.5-linux-x86_64.egg/cx_Freeze/freezer.py", line 605, in _Ve
rifyConfiguration
    self._GetInitScriptFileName()
  File "/home/mostafa/source/foo/venv/lib/python3.5/site-packages/cx_Freeze-5.0-py3.5-linux-x86_64.egg/cx_Freeze/freezer.py", line 625, in _Ge
tInitScriptFileName
    self.initScript = get_resource_file_path("initscripts", name, ".py")
  File "/home/mostafa/source/foo/venv/lib/python3.5/site-packages/cx_Freeze-5.0-py3.5-linux-x86_64.egg/cx_Freeze/freezer.py", line 99, in get_
resource_file_path
    if os.path.isabs(name):
  File "/home/mostafa/source/foo/venv/lib/python3.5/posixpath.py", line 64, in isabs
    return s.startswith(sep)
AttributeError: 'NoneType' object has no attribute 'startswith'

Comments (3)

  1. Anthony Tuininga repo owner

    I just pushed a change to resolve issue #32 and created a virtual machine with Ubuntu 15.10. I just did a freeze of the simple sample in the cx_Freeze repository. It worked perfectly without any changes whatsoever. Can you try doing the same thing and letting me know if you still have the issue?

  2. Mostafa Razavi reporter

    I have upgraded to Ubuntu 16.04 Beta since opening this issue and my current Python version is 3.5.1+. I updated to changeset 561 and re-ran the test. The error message is virtually the same:

    Traceback (most recent call last):
      File "/home/mostafa/source/cx_freeze/venv/bin/cxfreeze", line 4, in <module>
        __import__('pkg_resources').run_script('cx-Freeze==5.0', 'cxfreeze')
      File "/home/mostafa/source/cx_freeze/venv/lib/python3.5/site-packages/pkg_resources/__init__.py", line 724, in run_script
        self.require(requires)[0].run_script(script_name, ns)
      File "/home/mostafa/source/cx_freeze/venv/lib/python3.5/site-packages/pkg_resources/__init__.py", line 1650, in run_script
        exec(code, namespace, namespace)
      File "/home/mostafa/source/cx_freeze/venv/lib/python3.5/site-packages/cx_Freeze-5.0-py3.5-linux-x86_64.egg/EGG-INFO/scripts/cxfreeze", line 5, in <module>
        main()
      File "/home/mostafa/source/cx_freeze/venv/lib/python3.5/site-packages/cx_Freeze-5.0-py3.5-linux-x86_64.egg/cx_Freeze/main.py", line 176, in   main
        silent = options.silent)
      File "/home/mostafa/source/cx_freeze/venv/lib/python3.5/site-packages/cx_Freeze-5.0-py3.5-linux-x86_64.egg/cx_Freeze/freezer.py", line 144, in __init__
        self._VerifyConfiguration()
      File "/home/mostafa/source/cx_freeze/venv/lib/python3.5/site-packages/cx_Freeze-5.0-py3.5-linux-x86_64.egg/cx_Freeze/freezer.py", line 451, in _VerifyConfiguration
        executable._VerifyConfiguration(self)
      File "/home/mostafa/source/cx_freeze/venv/lib/python3.5/site-packages/cx_Freeze-5.0-py3.5-linux-x86_64.egg/cx_Freeze/freezer.py", line 605, in _VerifyConfiguration
        self._GetInitScriptFileName()
      File "/home/mostafa/source/cx_freeze/venv/lib/python3.5/site-packages/cx_Freeze-5.0-py3.5-linux-x86_64.egg/cx_Freeze/freezer.py", line 625, in _GetInitScriptFileName
        self.initScript = get_resource_file_path("initscripts", name, ".py")
      File "/home/mostafa/source/cx_freeze/venv/lib/python3.5/site-packages/cx_Freeze-5.0-py3.5-linux-x86_64.egg/cx_Freeze/freezer.py", line 99, in get_resource_file_path
        if os.path.isabs(name):
      File "/home/mostafa/source/cx_freeze/venv/lib/python3.5/posixpath.py", line 64, in isabs
        return s.startswith(sep)
    AttributeError: 'NoneType' object has no attribute 'startswith'
    
  3. Log in to comment