2

I created a python virtual environment by virtualenv and activate it, then I found I can use pyinstaller in this vir-env, but I had not "pip install pyinstaller" in it, why? And as comparison, I wrote 'import <not_installed_module>' in code, then it threw up 'module unfound' and it is as expected.

---- updated 1st ---- thanks to reminder, added my operation enter image description here

---- updated 2nd ----- thanks to comments, it shows the pyinstaller is still in system path enter image description here

leotsing
  • 89
  • 4
  • 1
    how you know it's part of virtualenv and not your system-wide installed one? – Marcin Orlowski Apr 24 '23 at 08:55
  • Yeah as @MarcinOrlowski said, you might be calling your system-wide interpreter, use `whereis python` (for linux) or `where python` (for windows) to see where your different python interpreters are. Then call pyinstaller as so `{path/to/desired/interpreter/python.exe} -m PyInstaller {args}`. Note that it's important to write `PyInstaller` and not `pyinstaller` when calling it this way. Hope this helps ! – Olivier Neve Apr 24 '23 at 09:08
  • 1
    a note: on linux you'd rather use `which` which will show you which exact binary will be used if invoked without full path, while `whereis` will show more items, which might be confusing – Marcin Orlowski Apr 24 '23 at 09:10
  • Good call, my bad, I'm not as good with linux cli as I'd like to be xD – Olivier Neve Apr 24 '23 at 09:13

1 Answers1

0

thanks to all comments, they help me get the answer:

when I enter vir-env, and not install pyinstaller, I run where pyinstaller (win-10) and get the system-wide installed one:

C:\Users\ME\AppData\Local\Programs\Python\Python310\Scripts\pyinstaller.exe

then I install pyinstaller in vir-env by pip install pyinstaller, and run where pyinstaller, I get two:

(prj_path)\.venv\Scripts\pyinstaller.exe C:\Users\ME\AppData\Local\Programs\Python\Python310\Scripts\pyinstaller.exe

now I run "pyinstaller ..." It calls the pyinsaller in vir-env

leotsing
  • 89
  • 4