So, I created a python program. Converted to exe using Py2Exe, and tried with PyInstaller and cx_freeze as well. All these trigger the program to be detected as virus by avast, avg, and others on virustotal and on my local machine.
I tried changing to a Hello World script to see if the problem is there but the results are exactly the same.
My question is, what is triggering this detection? The way in which the .exe is created?
If so, are there any other alternatives to Py2exe, Pyinstaller, cx_freeze?
You can try nuitka.
pip install -U nuitka
Example:
nuitka --recurse-all --icon=app.ico --portable helloworld.py
Website:
http://nuitka.net/
Maybe you need to install Visual C++ 2015 Build Tools for compile.
http://landinghub.visualstudio.com/visual-cpp-build-tools
If you download Nuitka package, you will find a Trojan files in the folder.
If you use this library, you will create a exe file with a Trojan embedded in the exe file.
It converts files much faster than other similar libraries with no errors.
Related
I would require some guidance in regards to installing a module/package in pycharm (free edition). I have to mention that i have not worked with this IDE yet and wanted to try it out on a little project containing smartcards.
When i try to install "pyscard" i get the error that boils down to
error: command 'swig.exe' failed: No such file or directory
People say just install SWIG, which i guessed already ^^.
The issue i have is that i actually have no idea how to... and none of the pages i found has really enlightended me on this issue.
I downloaded the zip "swigwin-3.0.12" but i am at a loss what to do with it now. EDIT: According to the SWIG page this is an already compiled version and i have to somehow make pycharm recognize that the folder it is in contains the swig.exe it requires.
EDIT2: Adding the folder containing the swig.exe to the PATH variable also did not work ... which i thought would be the issue
EDIT3+Answer:
Ok the link in the comments from "wp78de" was correct my problem was that pycharm/pc restart were needed for it to catch the added PATH variable to the swig.exe (for pycharm that is)
Any advice is appriciated.
Envoirment:
Windows 8.1 Pro 64-bit
Pycharm 2017.2.4
Python 3.6
Basically, you just have to add the directory that contains the swig executable the PATH environment variable. You can do it via CMD or the Windows UI.
If you have added swig to your path, you should be able to call it in the command prompt from any directory: open "cmd", and type swig --help" on that prompt.
A restart of PyCharm (or whatever your IDE is) and Windows might be required.
edit September, 2, 2017, 1pm
I eventually managed to build a .exe with pyinstaller after many episodes.
Unfortunately I failed to deal with the ‘theano’ module (that is required in my case by the ‘pymc3’ module) and I had to modify the .py files and give up part of the application. My description below has two aims: first it may help; second could anyone help me building a .exe for windows 7+, with the ‘theano’ module ?
reminder: My python 3 script opens a simple GUI made with Qt Designer in a ‘.ui’ file and imports pyqtgraph (with pyqt5), pymc3 (and thus theano that is required by pymc3), scipy, numpy, os, sys. It will be distributed on machines with Windows 7+. I tried to build a ‘.exe’ with py2exe, cx_freeze, pynsist and pyinstaller (I opened and updated several posts, this one is still opened: build a .exe for Windows from a python 3 script importing pyqtgraph and opening a GUI) but all failed. My best result (with pyinstaller) is described below after I had to give up theano.
the command line I ended up with is: pyinstaller —noupx —onefile —add-data “toto.ui;.” toto.py. But strangely:
1 the qt designer file ‘toto.ui’ is not included and must be distributed together with the .exe. Otherwise there is an error message when running the .exe saying toto.ui not found;
2 the ‘platforms’ directory from the ‘Library/plugin’ directory of the python environment must also be distributed along with the .exe. Otherwise there is an error message when running the .exe ‘this application has failed to start because it could not find the qt
platform plugin windows’ (but there is no error message from pyinstaller when building !)
3 the .exe is 220MB big ! it seems pyinstaller includes a bunch of useless things during the building.
pyqtgraph problem:
At first sight, the module ‘pyqtgraph’ seems to be incompatible with pyinstaller. Indeed, when the python code imports pyqtgraph, pyinstaller gives a SyntaxError: ‘yield’ inside async function. This seems to me very awkward (is this a bug in pyinstaller ?) because I had the impression from forums this is related to asynchronous generators that are only compatible with python 3.6, while pyinstaller works only with python 3.5- that is not compatible with asynchronous generators… so why does pyinstaller use this ? It turns out this bug-like feature is disabled in a new version of pyinstaller that is not released (and so not installed by default): pip install git+https://github.com/pyinstaller/pyinstaller, thanks to 9dogs (in comments). I also found it may help to explicitly write os.environ[‘PYQTGRAPH_QT_LIB'] = 'PyQt5’ or ‘PyQt4’ before importing pyqtgraph in the py file(s)
theano problem:
theano turns out to make several implicit imports that are not detected by pyinstaller. Thus the building looks ok but when running the .exe you get error messages like ‘no module theano.tensor.shared_randomstreams’. Unfortunately I failed to use the '--hidden-import' option of pyinstaller so I added explicitly the imports in the py file(s) (in this example ’import theano.tensor.shared_randomstreams’ ).
But this is not the end: after that, the file ‘…\AppData\Local\Temp_MEI35682\theano\gpuarray\blockgemv.c' is missing, leading to [4128] Failed to execute script. I don’t know what this file is and didn’t find information. I gave up and removed part of the GUI to avoid theano. Can anyone help me using theano with pyinstaller ?
Whenever I try to load a PNG using SDL_Image's IMG_Load function it gives the error Failed loading libpng16-16.dll:. I have all the right dll's in the right path and I can use other parts of SDL_Image, but for some reason it can't load the libpng dll. How can I fix this? Any help is appreciated.
It appears that libpng16-16.dll has a dependency on zlib1.dll for MinGW-w64 (32-bit). Try to include zlib into your dependnecies--include the DLL in the folder where the executable runs.
See my article "SDL2: Loading Images with SDL_image":
If you're going to run from Visual Studio, make sure the image is in the same folder as your main.cpp file; otherwise if you're running straight from the executable, the image should be in the same folder with it.
Needless to say, what I wrote about the image here goes for the DLLs as well.
The VS do not searches dlls on anywhere except the execution dir, so you probably need to copy that dll to the Debug/ directory on your solution's path.
Very niche answer, but for those running into this issue because of pySDL2, it could be caused because your python interpreter is sub-par. For me, using the windows store install for python interpreter 3.10, gave this issue. However, when I switched to 3.10 from python.org all my issues were fixed.
This link show you how to set up SDL library/libpng16-16.dll to be available for acceess by the compiler.exe (the last step right before the sample code)
yourProgram proprety page -> Builds event-> post-build event
in my case i have
copy “C:\Users\MehdiB\Desktop\C Program\Library\SDL2-devel-2.0.4-VC\SDL2-2.0.4\lib\x86\SDL2.dll” “$(OutDir)SDL2.dll”;
copy “C:\Users\MehdiB\Desktop\C Program\Library\SDL2_image-devel-2.0.1-VC\SDL2_image-2.0.1\lib\x86\SDL2_image.dll” “$(OutDir)SDL2_image.dll”;
copy “C:\Users\MehdiB\Desktop\C Program\Library\dll\libjpeg-9.dll” “$(OutDir)libjpeg-9.dll”
here where you can get this dll
i just replaced zlib1.dll in system32 and SysWOW64 with the one downloaded from
https://github.com/OctaForge/OF-Windows/blob/master/bin_win32/zlib1.dll
.and worked nicely
Is it possible to create Windows executable files for Python and C/C++ code within the Eclipse workbench? If yes, then how can this be done?
This is how I create .exe files from eclipse, in windows. Is not within the eclipse workbench but it might help you. To avoid problems, I would recommend to download everything for 32 bit even if you use 64 bit computer.
Install python 2.6
Install Eclipse
Install py2exe
In eclipse go to Help > Install new software and install pydev plugin from http://pydev.org/updates/
In windows preferences point the python interpreter to the location of your python.exe in your computer (C:/Python26)
you might need to add py2exe to the libraries
create a python module called setup.py with a code similar to this one:
from distutils.core import setup
import py2exe
setup(windows=['H:/yourworkspace/YourPythonProject/src/yourprogram.py'])
open windows console and type
python H:/yourworkspace/YourPythonProject/src/setup.py py2exe
this will create a .exe located in C:/Python26/dist folder. It should work if you double click it but you cannot take it to a computer without python or any of the libraries that you´ve used. To do that, you can use Inno Setup.
It's very easy to use, basically it will ask for the location of the .exe, the dlls and folders that you want to add (I don't know about this so I add most of the things inside my C:/Python26/dist and it works). Inno setup will create an script and generate a .exe that you can install in any computer. You might need to edit the [Icons] part of the script, I had problems with that before to add an icon to the application.
That should hopefully work,
good luck.
Not sure I understand what you're asking as you're mixing Python/C++ in your question...
If you want to embed Python in some library, Google for 'embed python in c++'
If you just want to package Python to run Python code with extension modules, search for py2exe or cx-Freeze (personally, I like cx-Freeze better).
I don't think any of this is PyDev/Eclipse dependent (this should be IDE agnostic).
In addition to Fabio's answer:
In terms of C/C++, if you compile it on windows, eclipse does create yourprog.exe file automaticaly in order to be executed (in case if you have your main function written in C/C++). Look for your executable in bin folder of your project.
In terms of compiler: I use Cygwin. It simulates Linux environment. It contains (not by default though) g++ compiler, which, because of cygwin, compiles it in binary that can be launched in Windows (i.e. .exe file). I am not sure exactly about whether Linux binary is then converted to Windows binary or it is directly compiled for windows, but I know that this .exe file alone works if you run it.
Let me know if you need help installing Cygwin.
Dear stackoverflow members,
I have a question that might sound silly to most of the members here, but it is bothering me for quite a while now and couldn't find any appropriate answer for it, yet.
My question is, how can we run a source code or binary of a open source project which is distributed under GNU license.
When I download the project, all I get is a .tar file, when unzipped, I get a folder containing many sub-folders, like src, build and etc. This folder looks similar to the project folder created by an IDE like netbeans. But how can I compile and modify these source file?
Is there an application that does it? or do i have to switch to linux to do it?
I am currently using a copy of windows 7 and also have a copy of windows xp at disposal.
Any help would be very much appreciated.
Thank you very much in advance.
cheers
Kishore.
Under GNU and GNU/Linux distros the packages are installed by the package manager (e.g. no need to build or download anything). Some programmers distribuite (along with the source code) binary versions of the program (which you run by clicking on them, or by invoking them from the command line). You can compile source code on Windows thanks to MinGW. For the istructions to run read the `README' file that you find in the unpacked dir. Most programs can be build with:
./configure; make; make install
If you post the link to the project I could help you with the building process.