"Cannot read file" error when loading an .svg file with PyQt4 - python

I'm having troubles using a .svg icon for my windows icon. From what I have read this is due to a bad installation of the PyQt4 plugins, but I am confused on how to fix it.
When I try to load the image
self.setWindowIcon(QtGui.QIcon("File-View-front.svg"))
Here is the error message I get:
Cannot read file 'C:/Users/user/PycharmProjects/proj1/File-
View-front.svg', because: (line 2)
I tried printing the supported image formats with
for imageType in QtGui.QImageReader.supportedImageFormats():
print(imageType)
Which outputs:
b'bmp'
b'pbm'
b'pgm'
b'png'
b'ppm'
b'xbm'
b'xpm'
So I am missing formats... If I add the correct plugin path with
QtCore.QCoreApplication.addLibraryPath('C:/ProgramData/Anaconda3/Lib/site-packages/PyQt4/plugins')
(which if I understand correctly I could also do using conf.py, but I could not get that to work either)
I do get every format (including b'svg') using QtGui.QImageReader.supportedImageFormats(), but the error remains.
I am using Anaconda 4.3.1 and I installed PyQt4 with the wheel file I got here.

Related

Including Ghostscript when creating .msi with cx_freeze

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!

Why am I getting "`OSError: unknown file format`" when opening a TTF with `PIL.ImageFont`?

In Google Colab I am using PIL (Python Imaging Library). I have uploaded a TrueType Font MSMINCHO.TTF.
I am attempting to read it with fnt_kanji = ImageFont.truetype('./MSMINCHO.TTF') but I get the error "OSError: unknown file format".
I know the font is valid because it displays correctly in my local system. And the encoding is Unicode as it should be, since this font contains kanji (Chinese characters). And the filepath is also valid and correctly cased (otherwise, "OSError: cannot open resource" is thrown instead).
I've been searching for the solution in the docs and the web for more than half an hour and haven't found it.
Try changing your line to:
fnt = ImageFont.truetype('./MSMINCHO.TTF', layout_engine=ImageFont.LAYOUT_BASIC)
if that doesn't work you can try refreshing your pillow module like this:
pip uninstall pillow
python3 -m pip install -U https://github.com/python-pillow/Pillow/archive/master.zip

Incompatibility pyinstaller and sklearn

I'm trying to create a .exe file com a .py file using auto-py-to-exe, that uses pyinstaller for creating the file.
The problem is, on codes that I import the sklearn lib, I get the following error on opening the output exe file:
enter image description here
I have already tried including hidden imports from sklearn, cx-freeze, sklearn.neighbors.typedefs','sklearn.neighbors.quad_tree','sklearn.tree._utils' and sklearn.utils._cython_blas.
Also tried one file and one directory, both with same problem.
Also tried directly using pyinstaller, with same error. It works fine on codes without sklearn. Tried on python versions 3.6, 3.7 and 3.8.
Does anyone have a glue on how to solve this problem?
Thank you.

No module named itk (Insighttolkit) in Python

I am novice in python and Simple_ITK both to process .mha 3D image files. I have two problems:
When ever I install ITK, I always get an error as shown below:
and somehow I install ITK It doesn't work at all having no connectivity with python. And I also tried python-insighttoolkit3 package then it shows and error of
" Can't down load Python 2.8:i386" in Ubuntu software Center. I have tried various methods to install Insight Tool Kit in Ubuntu whatever I found but most of the time I get the same error as shown in picture above.
So can anybody guide me how to install and build ITK so that no error like no module named itk found.
Now another problem is I have a .py file and it has a class in which I have to fed input externally otherwise it will consider as None. SO I tried to call the file as
import /path/to/file/xxx.py
but it gives an Syntax error: invalid syntax
so how to call class from a python file from python Console .
Now, I'm using Ubuntu 15.02. For any missing details please ask.
Thanks.
1- For what I see in the image, I see that you are trying to install ITK instead of SimpleITK. For SimpleITK it is very simple using a linux package installer, like pip or easy-install. in this link you have the instructions to install it correctly. Remember to execute the instructions as super user. Maybe it is the reason of your error ( I can't see the instruction you are writing in the console ).
2- I recommend you to read the Python tutorial for modules The fastest way is to be located first on the directory of your .py file. The sequence would be:
cd /path
import module.py

(Python) PyInstaller unicode error

I'm trying to compile a webscraper that I'm working on to see if it will run properly on other systems. I'm using pyinstaller 3.0. Followed install instructions, installed prerequisites, no errors.
When I try to compile it using:
pyinstaller wowscrape.py
I get this unicode error:
...
File "C:\Users\brian_000\Documents\GitHubVisualStudio\wowscrape\wowscrape\wowscrape\wowscrape.py" line 1
\ufeffimport os
^
SyntaxError: invalid character in identifier
The only stuff I could find on unicode and pyinstaller had to do with installing it on linux.
I dug through the build folder and noticed that inside the "base_library" rar that there are handlers for unicode, so I'm not sure what it's getting hung up on.
I'm using Python 3.4, in this project I have:
os
sys
urllib
bs4
pyqt5
loginwindow << is an import from qt designer converted to python
mainwindow << is an import from qt designer converted to python
If there isn't a way to make this work with pyinstaller, are there any other options? I haven't seen much support for packing Python 3 into exe's with cross system support. Since it's a scraper based around WoW, I would like to have this produce applications for Win/Mac/Nix.
Thank you in advance.
Here is the main script I'm trying to build, if it will help.
I know, it's messy and long. It's still being prototyped.
link to code
Save your file in an editor encoded as UTF-8 without byte order mark (BOM) and try again. A decent editor should have a menu entry such as File --> Save with encoding.

Categories

Resources