pyinstaller asks for dependency that has assuredly been provided in venv and -p

Viewed 664

Trying to make an executable python module into an .exe using pyinstaller. So I

  • created an environment: c:\Python39\python.exe -m venv %DIR_BASE%,
  • activated it: %DIR_BASE%\scripts\activate, and finally
  • wrote a requirements.txt including the line jsonschema, saying
  • python -m pip install -r requirements.txt

Now the master command accessing the pyinstaller.exe. that per se knows nothing of the new environment beyond the -p parameter I give it, and which I hoped would suffice:

C:\python39\scripts\pyinstaller
  -p "X:\paws\src\shared\python;X:\paws\PyEnv\Py39\Lib\site-packages;
    X:\paws\PyEnv\Py39\Lib\site-packages\jsonschema;
    X:\paws\PyEnv\Py39\Scripts"
  -n ptGui
  %DIR_BASE%\prototype_gui\__main__.py

Alas, I got:

  File "c:\python39\lib\site-packages\pkg_resources\__init__.py", line 785, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'jsonschema' distribution was not found
  and is required by the application

However, I am pretty positive that the environmental(!) installation of that package succeeded:

(Py39) X:\paws\PyEnv\Py39\Lib\site-packages>ls -1 | grep jsonschema
jsonschema
jsonschema-3.2.0.dist-info

Pretty sure that is some beginners misconception. Does anyone of you see it, and would tell me how to do it right?

1 Answers

I can answer my own question. Apparently it is wrong to install pyinstaller on the base installation, use it from there, and expect everything to work.

Instead of C:\python39\python -m pip install pyinstaller I now use

X:\PyEnv\Py39\Scripts\activate
python -m pip install pyinstaller

yielding an env-specific X:\PyEnv\Py39\Scripts\pyinstaller.exe. Using that all was good.

Related