how to recompile the bootloader of Pyinstaller - python

I have an AntiVirus false positive problem of my exe file generated using PyInstaller, by searching i found this answer witch consist of recompiling the bootloader and i just can't get it done.
This what i've tried so far:
try to install C++ build-tools with choco using "choco install -y vcbuildtools" for some reasons the installation failed.
installing visual studio community from here then goes to "cd bootloader" and do python ./waf distclean all got the error can't open file './waf': [Errno 2] No such file or directory
installing MinGW-w64 and setting the path then retry, i got the same error.
Or maybe there is another way to make the executable not detected as virus/trojan.
Packages used : PyQt5, pysnmp, pandas, numpy.
EDIT:
Thanks to #Ana Knickerbocker answer i was able to make a progression, now when i run python ./waf all i got the error :
Python Version : 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)]
Checking for 'msvc' (C compiler) : not found
Checking for 'gcc' (C compiler) : not found
Checking for 'clang' (C compiler) : not found
could not configure a C compiler!
I guess i still don't have a compiler, i've tried pip install vsbuildtoolsbut i got this message : No matching distribution found for vcbuildtools any ideas ?
Im on Windows 7 x64

Hey you don't need visual studio to build pyinstaller's bootloader, you can do it in your terminal if you have python or python3 installed. It's important to know which one you are using.
I will assume you use python3, try the following steps in your terminal/command line:
1) git clone https://github.com/pyinstaller/pyinstaller
2) cd pyinstaller, then cd bootloader
3) Run “python3 ./waf distclean all” to build the bootloader for your system.
4) Once the bootloader has been built, type in: “python3 setup.py install”
5) This should have installed pyinstaller. Type pyinstaller in the terminal and hit enter. It should recognize the command, but it will complain about more arguments.
6) Use the command "pyinstaller yourfile.py" to create your executable.
Hope this helped!

For anyone getting the error 'could not configure a C compiler!
Simply install a C compiler on your machine.
I installed Visual Studio with C++ compiler as was easier and more legitimate.
https://visualstudio.microsoft.com/vs/features/cplusplus/

The bootloader source is not installed if you are using pip install …. You need to use a source package of PyInstaller (either a git clone or download an archive from github).
GitHub - Bootloader Issue
PyInstaller GitHub

Related

Pip install results in this error " cl.exe' failed with exit code 2 "

I've read all of the other questions on this error and frustratingly enough, none give a solution that works.
If I run pip install sentencepiece in the cmd line, it gives me the following output.
src/sentencepiece/sentencepiece_wrap.cxx(2809): fatal error C1083: Cannot open include file: 'sentencepiece_processor.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
[end of output]
I'm running python 3.10.1 and pip 22.0.3 .
*I have the following Microsoft Visual C++ programs on my windows machine,which I've just done a fresh install of as it was complaining of not having a particular C++ program.
MS VC++
I've even added the .exe file to my PATH variables but still I get the same error.
Am I missing a particular Microsoft program on my pc?
I haven't seen this problem in Windows, but for Linux, I would normally reinstall Python after installing the dependencies (such as the MSVC thing). In that case this is especially helpful because I'm often rebuilding (compiling and other related steps) Python/Pip.
Could also just be an error specific to the module and Python version combo you're trying.
From a discussion in the comments:
I have the pyenv-win version manager, so I was able to create venvs and test this for you. With Python 3.10.2, it fails; with Python 3.8.10, it's successful. So, yes, reinstalling does seem to be worthy of your time.
With python3.10
On Windows: First, install vcpkg and install sentencepiece:x64-windows-static
copy the header and lib files from vcpkg/installed/x64-windows-static/include and lib to
C:/Program Files/python310/build/root/include and lib
This should work as the setup.py install expects the library in a ..\build\root\lib directory.
As the C:\Program Files\python310\lib is in the /LIBPATH, the resulting ..\build\root\lib will point to the sentencepiece.lib
If still encounting errors, then set the INCLUDE and LIB environment variables so that the cl.exe , which is called from pip install sentencetransformers finds them.
People having windows+python 3.10 env, here are exact steps to install it via vcpkg.
Other instructions are covered in zweistein's answer.
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install sentencepiece:x64-windows-static

Error in installing Matplotlib : fatal error C1083

I am relatively new to Python coding and want to learn about statistics and data management in Python. For this I would like to install Matplotlib, which is giving me some issues.
I see other people having this issue, but I have not fully understood how to fix it.
To install i use
pip install matplotlib
I have the following specs installed
Windows 10
Python 3.8
Microsoft Studio 2019
The first error i got was to install Microsoft Studio, so I did that.
I have also attempted to update pip
BUILDING MATPLOTLIB
matplotlib: yes [3.1.1]
python: yes [3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)]]
platform: yes [win32]
...
checkdep_freetype2.c
src/checkdep_freetype2.c(1): fatal error C1083: Cannot open include file: 'ft2build.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.23.28105\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
----------------------------------------
ERROR: Command errored out with exit status 1:
You have python 3.8, not python 3.7.
But there are no python 3.8 wheels available for matplotlib 3.1.1 on pypi. So best remove python 3.8 completely and install python 3.7.
When you then run python -m pip install matplotlib it will install the compiled version from the wheels, so there is no need to compile anything yourself or have Microsoft Studio available.
After spending a lot of time on the issue, this helped me to solve it:
python -m pip install -U matplotlib==3.2.0rc1
FYI: the matplotlib website installation instructions has some info on installing from source.
For Windows it states setting include path and link path:
set CL=/IC:\directory\containing\ft2build.h ...
set LINK=/LIBPATH:C:\directory\containing\freetype.lib ...
As a workaround you may install matplotlib on Windows using the 'Unofficial Windows Binaries for Python Extension Packages' with pip install <downloaded_filename>.
Tested on Python 3.8, Windows 10 and matplotlib-3.2
https://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib

How to fix : pyconfig.h not found with Anaconda

I am setting up boost-python for the python bindings of a library. Previously, boost was installed but linked against python2.7. After some tribulations, everything from the previous boost install is gone and I am trying to install a fresh boost.
I am using Linux Mint for the record, and Anaconda with python 3.6.8.
It works correctly in the CLI : python --version gives 3.6.8
I then begin to follow the instructions for building boost : https://www.boost.org/users/history/version_1_69_0.html
What I got from other threads is to do this :
sudo apt-get install python3-dev
I am not sure I am supposed to since I have anaconda3 but anyway, I did it.
./bootstrap.sh
here the file project-config.jam is created and the line about python says :
using python : 3.6 : /home/myUser/anaconda3 ;
I then proceed to build with b2 :
sudo ./b2 --with-python -j8 install
the installation fails with literally a wall of text full of these :
./boost/python/detail/wrap_python.hpp:50:11: fatal error:
pyconfig.h: No such file or directory
# include <pyconfig.h>
^~~~~~~~~~~~
compilation terminated.
When I search inside ~/anaconda3/include/python3.6m the file pyconfig.h sits there as expected
Is there additional information I should give to b2 or bootstrap ?
I face the same problem for installing boost 1.70 and Anaconda3 with python Anaconda with python 3.7.1. I found an answer based on this question.
Ubuntu - Linking boost.python - Fatal error: pyconfig cannot be found
By the way to solve this problem first you should find the "pyconfig.h" file in the installation directory of Anaconda. For me it's in "~/anaconda3/include/python3.7m". Then export this address or just add this address to the .bashrc file.
export CPLUS_INCLUDE_PATH="$CPLUS_INCLUDE_PATH:path/to/your/Anaconda3/include/python3.7m"
Put the address to Anaconda in your pc instead of path/to/your/Anaconda3. Remember to restart the terminal after this. Then again just run "./b2" in the boost folder. It should compile the rest.

Could not import cufflinks

Problem
I am trying to install both plotly and cufflinks. However I had a problem.
The installation of both plotly and cufflinks were successful. Although, I can't import cufflinks.
Below is a picture of the problem. It seems to be a dependency error:
I tried manually downloading and installing "talib" but I keep getting failures. (Shown below).
talib\common.c(240): fatal error C1083: Cannot open include file: 'ta_libc.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
Any Ideas? I tried re-installing both modules and Anaconda. Nothing So far.
Other infos:
Cufflinks version: 0.11.0
Plotly version: 2.0.10
Anaconda version: 3-4.4.0 (But I don't think it have anything to do with it)
Python version: 3.6.1
try installing this version of cufflinks, it eliminated the error for me.
pip install cufflinks==0.8.2
From this link: github.com/mrjbq7/ta-lib#troubleshooting
Troubleshooting
Sometimes installation will produce build errors like this:
func.c:256:28: fatal error: ta-lib/ta_libc.h: No such file or directory
compilation terminated.
This typically means that it can't find the underlying TA-Lib library, a dependency which needs to be installed. On Windows, this could be caused by installing the 32-bit binary distribution of the underlying TA-Lib library, but trying to use it with 64-bit Python.
Windows
Download ta-lib-0.4.0-msvc.zip and unzip to C:\ta-lib
This is a 32-bit release. If you want to use 64-bit Python, you will need to build a 64-bit version of the library.
My Fix
So, for windows, we need a 64-bit version of the library? Luckly I found a lot of modules built for 32 and 64 bits python:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
search for "ta-lib" and click on the module you need (In my case cp36 64 bits).
Then, open the command prompt.
Change to where you downloaded the file: cd path/to/file
Type: pip install NameOfFile (in my case pip install TA_Lib‑0.4.10‑cp36‑cp36m‑win_amd64.whl )
Now the 64-bits Ta-Lib module should be installed in your machine. I tested the previous line of codes and it worked!
Thanks for the help :)
I have now removed all dependencies on talib. All studies are pure python based now and you should not face any of this errors.

Problems with installing Cython on a computer running Windows 7

I am trying to install Cython on a computer running Windows 7. I am using MinGW for my C-compiler. I've taken the following steps:
Installed MinGW.
Added C:\MinGW\bin to Path. Made sure Path included no empty spaces.
Created the file distutils.cfg in the distutils directory. It reads:
[build]
compiler=mingw
[build_ext]
compiler=mingw
I start the command prompt, got to the proper directory and type "python setup.py install". I get the following output:
running install
running build
running build_py
running build_ext
building 'Cython.Plex.Scanners' extension
error: Unable to find vcvarsall.bat
As far as I've understood, this is an error regarding setting MinGW as the C-compiler, but I've aldready included it into Path. What more can I do? Where do I go from here?
Open CMD and type:
SET VS90COMNTOOLS=%VS100COMNTOOLS%
Change the numbers for the edition value of Visual Studio you are running :)
Possibly stolen from here: error: Unable to find vcvarsall.bat
EDIT:
you can download the necessary packages from here:
http://go.microsoft.com/?linkid=7729279
It also sets VS90COMMNTOOLS for you :)
Why wont You use prebuilded packages from
Here
?
I also tried compiling Cython and also failed. This way is far easier :)

Categories