在 anaconda 环境中使用 pyinstaller

Gon*_*alo 6 python pyinstaller conda

我在 上制作了一个非常简单的应用程序python(v 3.6),我想使用 pyinstaller 冻结它。我使用 anaconda 创建的环境制作了该应用程序,并在那里安装了我需要的软件包(youtube_dl)。我需要有关如何使用我创建的环境(其中包含所有包)的应用程序(Main.py)使用 pyinstaller 的帮助。\n如果我运行“pyinstaller Main.py”,我会收到此错误:

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

如何使 pyinstaller 使用我在 anaconda\xc2\xb4s 目录中创建的环境?

\n

小智 8

pyinstaller通过发出以下命令从 anaconda 提示符重新安装

conda install -c conda-forge pyinstaller

这对我有用。


小智 3

看起来您youtube_dl在 anaconda 环境中安装了 pyinstaller,并且在 anaconda 环境之外运行 pyinstaller,但它找不到所需的模块。pip install youtube_dl你之前尝试过这样做pyinstaller Main.py吗?