ClimenteA/pyvan

TypeError: expected str, bytes or os.PathLike object, not NoneType

Closed this issue ยท 2 comments

I made a van.py file next to my flask app. These are the settings specified:

import pyvan
OPTIONS = {"main_file_name": "flask_app.py",
            "show_console": False,
            "use_pipreqs": True,
            "install_only_these_modules": [],
            "exclude_modules":[],
            "include_modules":[],
            "path_to_get_pip_and_python_embeded_zip": ""
            }

pyvan.build(OPTIONS)

Though I get this error (which I'm not sure what it means, I think it might have to do with the last parameter of path to get pip. I'm running MacOS Mojave, Python 3.7.

Traceback (most recent call last):
  File "van.py", line 11, in <module>
    pyvan.build(OPTIONS)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyvan.py", line 261, in build
    GET_PIP_PATH, PYTHON_EMBEDED_PATH, pth_file, zip_pyfile = process_options(OPTIONS)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyvan.py", line 226, in process_options
    FILES_PATH = os.path.join(os.getenv('USERPROFILE'), 'Downloads')
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/posixpath.py", line 80, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType

I tried finding those files online and adding them manually, I added get-pip.py from: https://bootstrap.pypa.io/get-pip.py
And I added Python 3.7.4: python-3.7.4-embed-amd64.zip
I placed both in a folder called 'pathtoe' and I set that folder to the parameter path_to_get_pip_and_python_embeded_zip

I ran, and now I have this new error. Does pyvan only work with windows?

Using python37 from:
 pathtoe/get-pip.py 
 pathtoe/python-3.7.4-embed-amd64.zip
Searching modules needed using 'pipreqs'...
Running command:  pipreqs . --force --ignore dist
INFO: Successfully saved requirements file in ./requirements.txt
b''
Done!
Checking which modules to exclude or to keep
Updating 'requirements.txt' file
File requirements.txt done!
Copying files..
Files copied to dist folder!
Extracting pathtoe/python-3.7.4-embed-amd64.zip to dist folder
Zip file extracted!
File 'get-pip.py' file copied to dist!
Moved runtime to dist folder:  /Volumes/Transcend2/flaskgui/dist
Making startup batch files
Done!
Uncommented 'import site' line from 'python37._pth' file
Extracting python37.zip file
Zip file extracted to python37.zip folder!
Installing pip..
Running command:  python.exe get-pip.py --no-warn-script-location
/bin/sh: python.exe: command not found
Traceback (most recent call last):
  File "van.py", line 11, in <module>
    pyvan.build(OPTIONS)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyvan.py", line 286, in build
    install_requirements()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyvan.py", line 162, in install_requirements
    execute_os_command("python.exe get-pip.py --no-warn-script-location")
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyvan.py", line 49, in execute_os_command
    raise Exception(command, exitCode, output)
Exception: ('python.exe get-pip.py --no-warn-script-location', 127, b'')

pyvan is mainly for windows.. (.exe is for windows on mac executables end with .app)
Linux and mac have already python installed and they don't have a python embeded version available to download.

If you want you can make a pull request and add the bellow requirements needed to run on linux/mac.

  • detect if os is windows if not skip the python embeded step and
  • just make a batch file that will start the script using the already installed python on linux/mac
  • also when started it should install the modules needed

The pyvan source file is not that big (about 300 lines) no complicated things going there.