ClimenteA/pyvan

Cannot use PyVan

Closed this issue · 5 comments

Dear

I am trying to use your pkg to make a portable app of my python script (tkinerer, selenium, seleniumbase) but for some reason I cannot

here is my van.py

import pyvan

OPTIONS = {
      "main_file_name": "main.py",
      "show_console": True,
      "use_existing_requirements": True,
      "python_version": "3.8.10",
      "download_missing_embedded_files": True,
      "use_pipreqs": True,
      "install_only_these_modules": [],
      "exclude_modules": [],
      "include_modules":['selenium', 'tqdm', 'tinkerer', 'seleniumbase', 'validators'],
      "path_to_get_pip_and_python_embedded_zip": "",
      "build_dir": "dist",
      "pydist_sub_dir": "pydist",
      "source_sub_dir": "sources",
      "icon_file": './logo.ico',
}

pyvan.build(**OPTIONS)

my repo structure is as follows

├── requirements.txt
├── van.py
├── main.py
├── logo.ico
├── web_actions_recorder
|         ├── main.py
|         ├── __init__.py
└── README.md

and i run the following in my terminal pyvan van.py and I get the following error trace code

===PYVAN BUILD CONFIGURATION===
Input dir: C:\SVC\web-actions-recorder
Build dir: C:\SVC\web-actions-recorder\dist
Python distribution will be installed in: C:\SVC\web-actions-recorder\dist\pydist
App source code will be installed in: C:\SVC\web-actions-recorder\dist
===REQUIREMENTS===
pyvan will try to resolve requirements for you using pipreqs and/or pip freeze:
use_pip_reqs: True
include_modules: ()
exclude_modules: ()
===BUILD OPTIONS===
pyvan will attempt to install python version: 3.8.10
requirements will be installed without additional pip arguments
===EXE FILE===
pyvan will generate an exe file for you in C:\SVC\web-actions-recorder\dist
pyvan will use the following settings:
main_file_name: van.py
show_console: True
no icon file was set.

===START PYVAN BUILD===
Resolved python_version 3.8.10: (3, 8, 10)
Using Python-3.8.10 from:
 C:\Users\Sheikh\Downloads\get-pip.py
 C:\Users\Sheikh\Downloads\python-3.8.10-embed-amd64.zip
Existing build directory found, removing contents... C:\SVC\web-actions-recorder\dist
Searching modules needed using 'pipreqs'...
Running command:  pipreqs C:\SVC\web-actions-recorder --force --ignore dist --savepath C:\SVC\web-actions-recorder\dist\requirements.txt
INFO: Successfully saved requirements file in C:\SVC\web-actions-recorder\dist\requirements.txt
b''
Done!
Checking which modules to exclude or to keep
Updating C:\SVC\web-actions-recorder\dist\requirements.txt file
File C:\SVC\web-actions-recorder\dist\requirements.txt done!
Copying files from C:\SVC\web-actions-recorder to C:\SVC\web-actions-recorder\dist!
Traceback (most recent call last):
  File "c:\users\sheikh\appdata\local\programs\python\python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\sheikh\appdata\local\programs\python\python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Sheikh\AppData\Local\Programs\Python\Python37\Scripts\pyvan.exe\__main__.py", line 7, in <module>
  File "c:\users\sheikh\appdata\local\programs\python\python37\lib\site-packages\click\core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\sheikh\appdata\local\programs\python\python37\lib\site-packages\click\core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "c:\users\sheikh\appdata\local\programs\python\python37\lib\site-packages\click\core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\sheikh\appdata\local\programs\python\python37\lib\site-packages\click\core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "c:\users\sheikh\appdata\local\programs\python\python37\lib\site-packages\pyvan.py", line 614, in cli
    path_to_get_pip_and_python_embedded_zip="" if path_to_get_pip_and_python_embedded_zip is None else path_to_get_pip_and_python_embedded_zip
  File "c:\users\sheikh\appdata\local\programs\python\python37\lib\site-packages\pyvan.py", line 414, in build
    build_dir=build_dir
  File "c:\users\sheikh\appdata\local\programs\python\python37\lib\site-packages\pyvan.py", line 60, in put_code_in_dist_folder
    dirs_exist_ok=True
TypeError: copytree() got an unexpected keyword argument 'dirs_exist_ok'

Q1. Please any help with that?
Q2. Is pyvan going to take all the libraries and packages into consideration when creating my .exe file or shall I do something else?

Thankyou for your time and efforts

Parameter dirs_exist_ok was added on Python version 3.8 you probably have installed on your system python 3.7 or bellow.
Upgrade to python 3.8 or above and it will work.

pyvan will install all packages from your requirements.txt file

@ClimenteA
I have done that and it works fine THANKS
Yet, I have this python package called tinkerer and it is not found when I run
python38 -m pyvan -py 3.8.10 main.py --use-existing-reqs
I have the following about regarding the tinkerer I get the following error:

Running command:  pip3.exe install --no-cache-dir --no-warn-script-location Tinkerer==1.7.2
Collecting Tinkerer==1.7.2
  Downloading Tinkerer-1.7.2.tar.gz (330 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: 'C:\SVC\web-actions-recorder\dist\pydist\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Sheikh\\AppData\\Local\\Temp\\pip-install-taik29k_\\tinkerer_d7d418ea56c543b9822499b5e6f91736\\setup.py'"'"'; __file__='"'"'C:\\Users\\Sheikh\\AppData\\Local\\Temp\\pip-install-taik29k_\\tinkerer_d7d418ea56c543b9822499b5e6f91736\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Sheikh\AppData\Local\Temp\pip-pip-egg-info-59_x2a5m'
       cwd: C:\Users\Sheikh\AppData\Local\Temp\pip-install-taik29k_\tinkerer_d7d418ea56c543b9822499b5e6f91736\
  Complete output (5 lines):
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\Sheikh\AppData\Local\Temp\pip-install-taik29k_\tinkerer_d7d418ea56c543b9822499b5e6f91736\setup.py", line 12, in <module>
      import tinkerer
  ModuleNotFoundError: No module named 'tinkerer'
  ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/97/99/1510307d73db6f3241ac673008bbaaac291666072a796d4e15e3a2931237/Tinkerer-1.7.2.tar.gz#sha256=5330a48f81bbe940084fb0c542fbe13e6e95a331cadf86bec8a904786bf08f46 (from https://pypi.org/simple/tinkerer/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement Tinkerer==1.7.2 (from versions: 0.1b0, 0.1.1b0, 0.1.2b0, 0.2.1b0, 0.3.1b0, 0.4b0, 0.4.1b0, 1.0, 1.0.1, 1.0.2, 1.1, 1.2, 1.2.1, 1.3.0, 1.4.0, 1.4.1, 1.4.2, 1.5, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.7.2)
ERROR: No matching distribution found for Tinkerer==1.7.2
FAILED TO INSTALL  Tinkerer==1.7.2
Running command:  pip3.exe install --no-cache-dir --no-warn-script-location tinkerer==1.7.2
Collecting tinkerer==1.7.2
  Downloading Tinkerer-1.7.2.tar.gz (330 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: 'C:\SVC\web-actions-recorder\dist\pydist\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Sheikh\\AppData\\Local\\Temp\\pip-install-h0znzjl9\\tinkerer_6438228754e64e6381fc90bbb98eb145\\setup.py'"'"'; __file__='"'"'C:\\Users\\Sheikh\\AppData\\Local\\Temp\\pip-install-h0znzjl9\\tinkerer_6438228754e64e6381fc90bbb98eb145\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Sheikh\AppData\Local\Temp\pip-pip-egg-info-pdzcid9c'
       cwd: C:\Users\Sheikh\AppData\Local\Temp\pip-install-h0znzjl9\tinkerer_6438228754e64e6381fc90bbb98eb145\
  Complete output (5 lines):
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\Sheikh\AppData\Local\Temp\pip-install-h0znzjl9\tinkerer_6438228754e64e6381fc90bbb98eb145\setup.py", line 12, in <module>
      import tinkerer
  ModuleNotFoundError: No module named 'tinkerer'
  ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/97/99/1510307d73db6f3241ac673008bbaaac291666072a796d4e15e3a2931237/Tinkerer-1.7.2.tar.gz#sha256=5330a48f81bbe940084fb0c542fbe13e6e95a331cadf86bec8a904786bf08f46 (from https://pypi.org/simple/tinkerer/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement tinkerer==1.7.2 (from versions: 0.1b0, 0.1.1b0, 0.1.2b0, 0.2.1b0, 0.3.1b0, 0.4b0, 0.4.1b0, 1.0, 1.0.1, 1.0.2, 1.1, 1.2, 1.2.1, 1.3.0, 1.4.0, 1.4.1, 1.4.2, 1.5, 1.5.1, 1.6.0, 1.7.0, 1.7.1, 1.7.2)
ERROR: No matching distribution found for tinkerer==1.7.2
FAILED TO INSTALL  tinkerer==1.7.2

I have tried the following

cd dist/pydist/Scripts 
python 38 -m pip install tinkerer

but it is already installed in my global env

Q1. Any Idea how to install it properly?

Maybe adding in requirements.txt Tinkerer==1.7.2 will solve it? I'm not sure..

@ClimenteA I have exhausted that approach and tried to used tinkerer==1.7.2 and tkinter==1.7.2 and tinkerer and tkinter yet nothing of them worked!

I have found the solution for my problem using PyInstaller, yet I will not close this issue by myself