Including Ghostscript when creating .msi with cx_freeze - python

I have a Dash app which uses Camelot in lattice mode and this needs Ghostscript to run. I know that using stream removes the need for Ghostscript, but I lattice works best for my use case.
I'm using cx_freeze to create a .msi that users can install. How can I include Ghostscript in the .msi file?
Without Ghostscript, users are getting this error - RuntimeError: Please make sure that Ghostscript is installed
I've tried including the Ghostscript folder in "include files" in setup.py, but the users are still getting the same error.
Thank you!

Related

PyCharm Isn't Autocompleting OpenCV [duplicate]

I cannot get autocomplete working for OpenCV (Python) on Windows.
According to Abid's instructions here, I pasted the cv2.pyd file in the C:\Python27\Lib\site-packages.
In the Python code, I import as follows:
import cv2.cv as cv
I have also installed numpy, and it created its own folder in site-packages unlike OpenCV (which I've pasted directly into site-packages).
With this setup, the code executes without any problems, even when OpenCV methods are called.
But I have not been able to get autocomplete to work. I have tried to get it to work on Sublime Text 2 (with SublimeCodeIntel) and PyCharm. In both IDEs, autocomplete works for the numpy import, but fails for the OpenCV import.
I'm using OpenCV 2.4.6, and Python 2.7 (32 bit).
Any possible solutions?
The reason it's not working is because you're using a .pyd file, which is essentially the same as a compiled .dll. Autocomplete works by reading the source .py files, which are plain text. Try installing the OpenCV and Intel Math Kernel Library optimized NumPy packages from Christoph Gohlke's Python Extension Packages for Windows repository, which is frequently updated and a must-use resource for anyone who does any kind of scientific Python computing on Windows. Make sure you delete the cv2.pyd and numpy directories from site-packages first. These new packages will install the .py source files needed by the autocomplete engine in Sublime Text.
EDIT
OK, so I wrote the above because it worked well for a bunch of other packages. I'm a Python 3 guy, and I never installed OpenCV from Gohlke because it only has Python 2 bindings. After reading #CrazyCoder's comment below, I booted up Win7, and indeed he's absolutely correct (and I should have realized this before) - since OpenCV is written in C/C++, the only .py file included in the Gohlke package is cv.py, whose entire contents are as follows:
from cv2.cv import *
The rest is contained in cv2.pyd and a bunch of .dlls. The full OpenCV Windows distribution from opencv.org is a 291 MB download, which expands to 3 GB, and the few .py files in there are involved in building OpenCV, and aren't any good for autocomplete purposes. So, unfortunately, I don't know if there's a solution to your problem at the moment. Just keep the docs handy, and perhaps check out OpenCV Computer Vision with Python from Packt/O'Reilly, published in April 2013.
I've had the same issue with PyCharm when building a custom version of OpenCV on windows. Here is what I did to fix it:
OpenCV made a folder in Python site-packages like so:
opencv site-packages
So what you need to do is just add the python-3.9 folder to your interpreter.
File
Settings...
Python interpreter
Three dots icon next to your interpreter -> Show all...
Select your interpreter and click on the "Show paths for selected interpreter" icon
Add the folder inside the cv2 site-packages
Now import the cv2 module normally.
The best way to solve all the problems of OPENCV-PYTHON is by uninstalling it and reinstalling it.
Even I faced the same problem.
I fixed it by:
python -m pip uninstall Opencv-python
Then I reinstalled it by using a lower version. But unfortunately, I did not know the versions of opencv; So by using a small trick you can get it by running:
python -m pip install opencv-python==
and you will get an error similar to this:
ERROR: Could not find a version that satisfies the requirement opencv-python== (from versions: 3.4.0.14, 3.4.10.37, 3.4.11.39, 3.4.11.41, 3.4.11.43, 3.4.11.45, 3.4.13.47, 3.4.15.55, 3.4.16.57, 3.4.16.59, 3.4.17.61, 3.4.17.63, 4.3.0.38, 4.4.0.40, 4.4.0.42, 4.4.0.44, 4.4.0.46, 4.5.1.48, 4.5.3.56, 4.5.4.58, 4.5.4.60, 4.5.5.62, 4.5.5.64) ERROR: No matching distribution found for opencv-python==
Here you can see all the versions of opencv-python; choose any one (but not the latest as the error occurs due the latest version of opencv-python. install it by using:
pip install opencv-python==3.4.17.61 (You can choose your version, but this version solved the issue for me)
then enjoy your coding....
Even AUTO-COMPLETE error in opencv-python gets solved.
HAPPY CODING

Can't load audio files with librosa

Unless I use one of librosa's native 'example' audio files which are in some format '.ogg', I cannot load audio.
Every github issue and SO answer says I need to install ffmpeg. I found a python package called ffmpeg and installed it into my virtual environment. I also found some sort of multi-purpose program called ffmpeg and installed it onto my Windows machine, and added it's location to my PATH variable.
I still get the same warnings and errors that everyone else is getting:
c:\users\wesle\appdata\local\programs\python\python38\lib\site-packages\librosa\core\audio.py:162: UserWarning: PySoundFile failed. Trying audioread instead.
warnings.warn("PySoundFile failed. Trying audioread instead.")
---------------------------------------------------------------------------
.
.
.
115 # All backends failed!
--> 116 raise NoBackendError()
I can find no resolution for this problem despite the number of people asking for help on it.
I don't know what fileformat you are trying to load, but in most cases installing ffmpeg is the solution to this problem. It is important to add the "../bin/" directory to PATH and restart the environment. Using the "set" command from prompt you can check that the current path contains the folder.

How to install FontForge Python plugin for Windows

I need some help with installation of FontForge Python on Windows.
I am trying to get ffpython to be usable across the whole system by
adding appropriate entried from fontforge-console.bat
redirecting the Python Path to FontForge installation path
The console said that Python is missing .dll files and I do not know what happened.
I tried searching for installation that comes with Python installation and came up nothing. THe documentations are too old and didn't give enough information to build my own. Current version is 2019-08-01 on Windows 10 1909. Please give any pointers on how to install FontFoge Python module.

Build with PyInstaller skipping libraries

i'm trying to build an app for windows using PyInstaller, but skipping libraries (ex django). I'm will run requirements.txt to use the installed libaries on local system python.
The intention is to compile (protect) the code and keep the libraries on system.
Saw about changing the python path on runtime using hook, but not found nothing.
Thanks for the help!
You can exclude modules on the command line like this:
pyinstaller --exclude-module django

Trouble with failing to build _tkinter after installing binary tcltk

I am running linux and python 2.7.14 I have successfully installed the binary version of tcltk. I installed it into the same directory as python27 such that the following directories were all added in the same folders, namely: include, lib, etc. The bits were not all found when I configured python again so when I checked the setup.py file it mentioned I could do the following, which I did:
make clean
./configure --with-tcltk-includes="-I/home2/bishopk2/python27/include" --
with-tcltk-libs="-L/home2/bishopk2/python27/lib/tcllib1.18 -ltclm.n -L/
home2/bishopk2/python27/lib/tklib0.6 -ltkm.n"
make TCLTK_INCLUDES="/home2/bishopk2/python27/include"
TCLTK_LIBS="/home2/bishopk2/python27/lib"
I have tried all permutations of this (i.e., with and without the tcllib1.18, ltclm.n, etc., etc.)
I am not sure the best way to share a config.log on stack overflow but here is a link:
https://www.pharmacoengineering.com/share-a-file/
(I made the pdf downloadable)
I had to save it as a pdf file so that it would upload to wordpress.
When I looked at it, I am not sure why the tcl.h file could not be found because when I:
find . -name "tcl.h"
It says that it is in my /home2/bishopk2/python27/include folder.
All of the libraries are there and it should be able to connect Tkinter with my tcl and tk libraries.
Any help would be greatly appreciated.
Best wishes,
Corey
tcllib and tklib and libraries of Tcl scripts.
To build tkinter you need to link to the binary shared object library (a .so file). This should be named libtcl8.6.so or something similar. It is not clear from your post that you realize tclM.N is a way of saying Major number, Minor number but you should put the numbers in for your installed version. So on my Debian based system I will provide --with-tcltk-includes=/usr/include/tcl8.6 --with-tcltk-libs=/usr/lib/x86_64-linux-gnu given your example. If you need to put in the library name then -ltk8.6 -ltcl8.6 (the linker drops the lib prefix from the filename.

Categories

Resources