4

I have a very simple application made on python(v 3.6), and I wanted to freeze it using pyinstaller.I have made the app using an environment created with anaconda, and I installed there the packages I needed(youtube_dl). I need help on how to use pyinstaller for my app(Main.py) using the environment I created with all its packages inside it. If I run "pyinstaller Main.py" I get this error:

Traceback (most recent call last):
  File "Main.py", line 7, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 631, in exec_module
    exec(bytecode, module.__dict__)
  File "youtube_downloader.py", line 3, in <module>
ModuleNotFoundError: No module named 'youtube_dl'
[2708] Failed to execute script Main
logout

How can I make pyinstaller use the environment I created at anaconda´s directory?

AMC
  • 2,535
  • 7
  • 12
  • 34
Gonzalo
  • 41
  • 1
  • 1
  • 2

3 Answers3

6

I reinstalled pyinstaller from anaconda prompt by issuing

conda install -c conda-forge pyinstaller

and it worked for me .

Bussller
  • 1,878
  • 5
  • 35
  • 43
piping piping
  • 61
  • 1
  • 3
2

Looks like you installed the youtube_dl in the anaconda environment and you are running the pyinstaller outside the anaconda environment and it can't find the needed module. Did you try just doing pip install youtube_dl before pyinstaller Main.py?

Michu93
  • 4,088
  • 5
  • 37
  • 64
Ontamu
  • 191
  • 1
  • 5
  • Yes! Thanks, that worked for me. But, I always use anconda enviroments to not conflict between packages, so, do you know how could I use pyinstaller inside that anaconda enviroment?? Anyway, thanks dude! – Gonzalo May 18 '18 at 13:22
  • 1
    Hello, probably you can install pyinstaller inside the anaconda environment and run it from there. Haven't tried it myself but it should work. – Ontamu May 21 '18 at 10:21
0

If you failed to run piping piping's answer.

Eg:

  • Using a very old version of Anaconda and you still have to use it.
  • Using very old pip.
  • You cannot access to pypi from host machine.

You may install pyinstaller manually.

Prerequisite

Assuming you have setuptools installed.

Example: PyInstaller 3.5 (for python 2.7) on linux

  1. Download PyInstaller 3.5

Check the requirements.txt

pefile; sys_platform == 'win32'
macholib; sys_platform == 'darwin'
altgraph  # <== you need this

dis3; python_version < '3.0' #<== and this
pywin32-ctypes; sys_platform == 'win32'
  1. Download and install dis3

    1. tar xzf dis3-0.1.3.tar.gz
    2. cd dis3-0.1.3
    3. python setup.py install or /somewhere/your/python2.7 setup.py install
  2. Download and install altgraph

    • Same as dis3
  3. Install PyIstaller

    • Same as above.
Louis Go
  • 2,031
  • 2
  • 15
  • 26