Code Monkey home page Code Monkey logo

Comments (15)

jfbramboll avatar jfbramboll commented on September 27, 2024

I'm getting the exact same error as here: http://stackoverflow.com/questions/26110026/pyinstaller-and-pythonnet-clr

I've tried cx_freeze, py2exe and pyinstaller. I'm using Python 2.7 64bit, Windows 7 64bit. and I have a bunch of .Net frameworks installed, including 4 and 4.5.

Is it at all possible to create an exe that using python.net?

from pythonnet.

den-run-ai avatar den-run-ai commented on September 27, 2024

@jfbramboll @kelvinomolumo PyInstaller should provide a hook to include pythonnet:

pyinstaller/pyinstaller#637

it is reportedly working for people here:
https://groups.google.com/forum/#!topic/pyinstaller/juS48yx3XyE

I am not sure about cx_freeze

from pythonnet.

den-run-ai avatar den-run-ai commented on September 27, 2024

pyinstaller has been updated to include proper clr (pythonnet) hook:

pyinstaller/pyinstaller#1801

from pythonnet.

konstantin-popov avatar konstantin-popov commented on September 27, 2024

In order to stop crashing with cx_freeze you need to manually add Python.Runtime.dll file from pythonnet package to your binary directory.

from pythonnet.

den-run-ai avatar den-run-ai commented on September 27, 2024

@konstantin-popov does cx_freeze allow configuring hooks for various packages so that this works by default?

from pythonnet.

konstantin-popov avatar konstantin-popov commented on September 27, 2024

Not sure, but I think it does, looking at this: https://github.com/anthony-tuininga/cx_Freeze/blob/master/cx_Freeze/hooks.py

from pythonnet.

den-run-ai avatar den-run-ai commented on September 27, 2024

@konstantin-popov feel free to submit a pull request to cx_freeze to implement this hook based on pyinstaller implementation. We cannot do anything about this in pythonnet without breaking a lot of code.

marcelotduarte/cx_Freeze#249

from pythonnet.

konstantin-popov avatar konstantin-popov commented on September 27, 2024

We cannot do anything about this in pythonnet without breaking a lot of code.

Sure. My reply was not a call to action, only a recipe how to deal with this specific problem - actually not with patching cx_freeze, but with adding a file to build using configuration options (option 'include_files').

The ticket you mentioned is actually about a different problem - failing to import custom .NET libraries in frozen app.

from pythonnet.

den-run-ai avatar den-run-ai commented on September 27, 2024

@konstantin-popov you need to update sys.path in order to custom load your .NET assemblies. See fairly complicated example for pyinstaller here:

#325

from pythonnet.

konstantin-popov avatar konstantin-popov commented on September 27, 2024

I do update sys.path and clr.AddReference('customlib') throws no exceptions - the problem appears later in code when importing the assembly.
I guess pythonnet hooks into python import system to load .NET assemblies, but after freezing the app with cx_freeze in doesn't work for some reason.

from pythonnet.

vmuriart avatar vmuriart commented on September 27, 2024

Is there a traceback available?

from pythonnet.

den-run-ai avatar den-run-ai commented on September 27, 2024

@konstantin-popov minimum reproducible example would be handy. Also make sure that your library does not reference other custom assemblies, maybe even during runtime.

from pythonnet.

konstantin-popov avatar konstantin-popov commented on September 27, 2024

Also make sure that your library does not reference other custom assemblies, maybe even during runtime.

That was exactly the thing. The library was external so I didn't guess it referenced somethine else. Thanks @denfromufa!

P.S. PR with a hook for pythonnet in cx_freeze

from pythonnet.

anthony-tuininga avatar anthony-tuininga commented on September 27, 2024

Pull request merged.

from pythonnet.

den-run-ai avatar den-run-ai commented on September 27, 2024

@jfbramboll @kelvinomolumo can you please verify that the pythonnet hook is now working in cx_freeze? @anthony-tuininga @konstantin-popov thanks for implementing this!

Anyway if any issues come up we can reopen this issue.

from pythonnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.