Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3.dll not found #4

Closed
fredrikaverpil opened this issue Jan 3, 2018 · 9 comments
Closed

python3.dll not found #4

fredrikaverpil opened this issue Jan 3, 2018 · 9 comments

Comments

@fredrikaverpil
Copy link
Contributor

fredrikaverpil commented Jan 3, 2018

Running python -m fbs run works fine, but python -m fbs freeze generates the following error:

(pyqt5_py35) C:\Users\iruser\code\repos\fbs-tutorial>python -m fbs freeze
Traceback (most recent call last):
  File "C:\Users\iruser\AppData\Local\conda\conda\envs\pyqt5_py35\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\iruser\AppData\Local\conda\conda\envs\pyqt5_py35\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\iruser\AppData\Local\conda\conda\envs\pyqt5_py35\lib\site-packages\fbs\__main__.py", line 4, in <module>
    main()
  File "C:\Users\iruser\AppData\Local\conda\conda\envs\pyqt5_py35\lib\site-packages\fbs\cmdline.py", line 17, in main
    args.cmd()
  File "C:\Users\iruser\AppData\Local\conda\conda\envs\pyqt5_py35\lib\site-packages\fbs\builtin_commands.py", line 35, in freeze
    freeze_windows()
  File "C:\Users\iruser\AppData\Local\conda\conda\envs\pyqt5_py35\lib\site-packages\fbs\freeze\windows.py", line 27, in freeze_windows
    remove(path('${freeze_dir}/' + dll_name))
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\\Users\\iruser\\code\\repos\\fbs-tutorial\\target\\Tutorial\\python3.dll'

When I look inside of fbs-tutorial\target\Tutorial, there's no python3.dll in there. Only a python35.dll.

@fredrikaverpil
Copy link
Contributor Author

Can we just print the error instead of halting?

		try:
			remove(path('${freeze_dir}/' + dll_name))
		except FileNotFoundError as error:
			print('Could not remove file:', error)

@fredrikaverpil fredrikaverpil changed the title python3.dll not found with Windows/conda environment python3.dll not found Jan 3, 2018
@mherrmann
Copy link
Owner

mherrmann commented Jan 3, 2018

Could it be that there's no python3.dll (but a python35.dll) because you're using Anaconda?

@fredrikaverpil
Copy link
Contributor Author

Hm, sounds odd but possible. I'll try to check this and report back.

@fredrikaverpil
Copy link
Contributor Author

fredrikaverpil commented Jan 4, 2018

Ok, I believe I found the root cause.

This conda install works just fine with fbs:

conda create -y -n fbs_py35 python=3.5 pyinstaller
activate fbs_py35
pip install PyQt5
pip install --no-cache-dir --force-reinstall -U fbs-0.0.6_SNAPSHOT-py3-none-any.whl
python -m fbs run
python -m fbs freeze
deactivate

This, however, produces the error where python3.dll is not found:

conda create -y -n fbs_pyqt5_py35 python=3.5 pyinstaller pyqt
activate fbs_pyqt5_py35
pip install --no-cache-dir --force-reinstall -U fbs-0.0.6_SNAPSHOT-py3-none-any.whl
python -m fbs run
python -m fbs freeze

Traceback (most recent call last):
  File "C:\Users\iruser\AppData\Local\conda\conda\envs\fbs_test\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\iruser\AppData\Local\conda\conda\envs\fbs_test\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\iruser\AppData\Local\conda\conda\envs\fbs_test\lib\site-packages\fbs\__main__.py", line 4, in <module>
    main()
  File "C:\Users\iruser\AppData\Local\conda\conda\envs\fbs_test\lib\site-packages\fbs\cmdline.py", line 17, in main
    args.cmd()
  File "C:\Users\iruser\AppData\Local\conda\conda\envs\fbs_test\lib\site-packages\fbs\builtin_commands.py", line 35, in freeze
    freeze_windows()
  File "C:\Users\iruser\AppData\Local\conda\conda\envs\fbs_test\lib\site-packages\fbs\freeze\windows.py", line 26, in freeze_windows
    remove(path('${freeze_dir}/' + dll_name))
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\\Users\\iruser\\code\\repos\\fbs-tutorial\\target\\Tutorial\\python3.dll'

The difference between the two scenarios is that I'm pip-installing PyQt5 (Qt5.9) in first scenario and in the second scenario I'm installing the conda-distribution of PyQt5 (Qt5.6). The conda-distribution is what's causing the issue.

I'm closing this issue as there is clearly fbs incompatibility issues with the conda-forge distribution of PyQt5. I've found these so far:

  • doesn't seem to be compiled with the --standalone argument, which means that the libraries are not found after pyinstaller has bundled everything up.
  • built against Qt 5.6
  • for some reason causes this issue where python3.dll is missing from the target\Target folder

Please note that the conda-distribution of PySide2 works fine with fbs, although it is compiled against Qt 5.6. I spoke too soon on this one. It seems also the PySide2 conda distribution is exhibiting this issue, where python3.dll is not found.

@mherrmann
Copy link
Owner

Interesting findings. Then the difference between Anaconda and vanilla Python is that the former has python35.dll while the latter has python3.dll. I could also imagine that there may be incompatibilities between PyQt 5.6 and PyInstaller 3.3+. Not sure.

@fredrikaverpil
Copy link
Contributor Author

fredrikaverpil commented Jan 4, 2018

Interesting findings. Then the difference between Anaconda and vanilla Python is that the former has python35.dll while the latter has python3.dll.

No, that's not what I compared. I compared two Anaconda installations. One with PyQt5.9 from pypi (no errors), and one with PyQt5.6 from conda-forge (could not find python3.dll).

Perhaps PyQt5 dictates which DLL files to be fetched by PyInstaller and these two different PyQt5 distributions does it in different ways.

EDIT: Also, if you download the zip archive of vanilla Python, you'll see both the python35.dll and the python3.dll right there in the zip - so I don't think it's a matter of either having one or the other. And in my Conda installation, I also see both of them:

12/18/2017  07:53 AM            50,688 python3.dll
12/18/2017  07:53 AM         3,952,640 python35.dll

I could also imagine that there may be incompatibilities between PyQt 5.6 and PyInstaller 3.3+

Possible. Either way, pip-installing PyQt5.9 is the right way to do it!

@liuh886
Copy link

liuh886 commented Feb 26, 2019

I try Anaconda with fbs after upgrading PyQt5.11 from PyQt5.6, and freeze is working but with huge size (over 500MB).

So decide go back to vanilla Python3.6, cleaned the environment variables of Anaconda.

And i got the same issue "python3.dll not found":
raise LookupError("Could not find %s on PATH" % file_name) LookupError: Could not find python3.dll on PATH
I am still working on it:

  1. python3.dll exist both on vanilla and Anaconda PATH.
  2. freeze size still big(200MB), look like pandas, matplotlib and numpy are the problems.
  3. reinstall PyInstaller and PyQt, doesn't work

Maybe I should uninstall Anaconda and try again.

@liuh886
Copy link

liuh886 commented Feb 27, 2019

update- I figure it out.

fbs/fbs/freeze/windows.py

 def _find_on_path(file_name):
    path = os.environ.get("PATH", os.defpath)
    path_items = path.split(os.pathsep)
    if sys.platform == "win32":
        if not os.curdir in path_items:
            path_items.insert(0, os.curdir)
    seen = set()
    for dir_ in path_items:
        normdir = os.path.normcase(dir_)
        if not normdir in seen:
            seen.add(normdir)
            file_path = join(dir_, file_name)
            if exists(file_path):
                return file_path
    raise LookupError("Could not find %s on PATH" % file_name)

I type os.environ.get in my virtualenv, and find there is anaconda enviroment variables remains. So just move it and restart explorer.exe. Test again, it works fine.

@mherrmann
Copy link
Owner

Happy to hear it. I want to improve support for Anaconda in an upcoming release. Many people are using it.

t0mpr1c3 added a commit to t0mpr1c3/fbs that referenced this issue Aug 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants