No such file or directory: 'gs' linux - python

I have a problem regarding using GhostScript to convert the ps file to JPG.
I have successfully got it to work in my Win7 machine, but for some reason it doesn't work in my Linux VM. I'm really not sure how to add the environment variables there(because that was needed in windows installation). Basically I'm testing it with the following code:
ps = cv.postscript(colormode='color')
img = Image.open(io.BytesIO(ps.encode('utf-8')))
img.save("wut.jpg")
But when executing it, I get the following error:
But when I type in "gs" in the command line in Linux, it says that it is installed:
Any kind of help would be highly appreciated. :)

In your shell, find the location of ghostscript with which gs.
Check that the path in python (os.environ['PATH']) contains the location of ghostscript.

Related

ImportError: libbz2.so.1.0: cannot open shared object file: No such file or directory || ONLY IN PYCHARM

I am using PyCharm on a fresh Linux installation. Every time I try to import librosa, pandas (or some other packages) I get the error:
ImportError: libbz2.so.1.0: cannot open shared object file: No such file or directory
The weird thing is that it works without any problems in the terminal. In PyCharm, however, it does not work.
I already tried to add the directory under which libbz2.so.1.0 is installed (/usr/lib/x86_64-linux-gnu) to the LD_LIBRARY_PATH.
I did that in my PyCharm run configuration and in the .bashrc.
Clearly, it is installed correctly in my packages, otherwise, I couldn't use it in the terminal so I don't know what else I can do.
Fixed it...
I initially installed pycharm via the software manager of linux mint.
Apparently, that was a mistake.
The error disappeared when I installed it based on the instructions given by jetbrains.com.
cent os version 7.
it worked for me
ln -s /usr/lib64/libbz2.so.1.0.6 /usr/lib64/libbz2.so.1.0

PySide6: error while loading shared libraries: libQt6DesignerComponents.so.6: cannot open shared object file

I'm trying to run QT Designer from the terminal
pyside6-designer
but get the error message:
venv/lib/python3.8/site-packages/PySide6/designer: error while loading shared libraries: libQt6DesignerComponents.so.6: cannot open shared object file: No such file or directory
Inspecting the folder, I can confirm libQt6DesignerComponents.so.6 exist in the folder:
/venv/lib/python3.8/site-packages/PySide6/Qt/lib
I have re-installed and also tried the alternative PIPENV, but same result. Trying to execute in the same folder it ask me to install qtchooser. But didn't work after installing this.
I am on Ubuntu 20.04. I can find a ticket saying it should be solved. link to solution
I have also tried some random stuff, such as
sudo /sbin/ldconfig -v
which is described here its foss. It didn't work.
Anyone got experience of the same problem and have a solution?
Set your LD_LIBRARY path in shell (bash) after activating a venv:
export LD_LIBRARY_PATH=/home/FILL_IN_USERNAME/PycharmProjects/pythonProject/venv/lib/python3.8/site-packages/PySide6/Qt/lib/
I'm running Kubuntu Groovy Gorilla.
I'm quite excited about trying this out.

Can't run Python programs from the terminal window, how do I fix this? (Windows 10, Python version 3.8.5)

I've been studying Python for a month now and normally I run all my programs in Sublime Text 3.
Today I learn to run Python programs in the terminal window as introduced in this section of the Automate the Boring Stuff with Python book following this video. Basically, I followed the instruction in the video and created the hello.py file as below:
#! python3
print('Hello, World!')
Then I opened the Command Prompt to run the file with the command: py.exe c:\users\danh\mypythonscripts\hello.py,
an error pops-up and states that "This app can't run on your PC" and a line says that Access is denied. I spent the whole day trying to fix this problem but still I couldn't get it running.
One thing is when I change the directory of the Command Prompt to run the file to C:Windows\system32 (or run the Command Prompt as Administrator) and then run the command py.exe c:\users\danh\mypythonscripts\hello.py, it runs the file without any problem as in this image.
Does anyone know how to fix this problem? Any help is appreciated. Thanks!
I solved the problem.
When I looked into my user directory at C:\Users\<Username>, it appears that there is a py.exe file that has 0 bytes.
I was told in this thread that the py.exe file shouldn't be in my user directory so I removed that file and it fixed the problem.
I still don't know how the py.exe file got into my user directory and why it has 0 bytes so I'm not sure this solution could help others. For now, I will accept my own answer because it solves the problem in my case.
It looks like you're trying to use Microsoft's new Windows 10 Metro-based auto-installing version of Python. It's included by default but, as you've found, it doesn't work very well.
Try installing the version from the Python website.
If you've got a 32-bit copy of Windows, make sure to install the 32-bit version; Windows isn't very good at running 64-bit programs from a 32-bit kernel. You can check by looking in your C: drive; if you haven't got a Program Files (x86) folder, install the 32-bit version.
python.exe inside my env\Scripts\ became 0kb for some reason. So I created another virtual-env and copied python.exe from there to this folder. then it started working.

MoviePY can't detect ImageMagick binary on Windows

I just got myself a new laptop, wanted to setup MoviePY on that new Windows 64x (Python3.7.0) machine. I triple checked everything but when it comes to text part of my code, it throws that error at me;
OSError: MoviePy Error: creation of None failed because of the following error:
OSError: [WinError 6] The handle is invalid
"ImageMagick is not installed on your computer, or (for Windows users) that you didn't specify the path to the ImageMagick binary in file conf.py, or that the path you specified is incorrect"
My config_defaults.py file;
import os
FFMPEG_BINARY = os.getenv('FFMPEG_BINARY', 'ffmpeg-imageio')
#IMAGEMAGICK_BINARY = os.getenv('IMAGEMAGICK_BINARY', 'auto-detect')
IMAGEMAGICK_BINARY = "C:\\Program Files\\ImageMagick-7.0.8-Q16\\magick.exe"
The path is correct and both magick.exe and convert.exe exist in that path. I'm also sure ImageMagick is properly installed. When I type convert in cmd, it prints "ImageMagick 7.0.8 Q16 x64" and bunch of other stuff.
What am I missing here?
I had the same error as you but my problem was that I did not properly installed ImageMagick : in the installation wizard you need to check "install legacy utilities".
So I reinstalled it, checked this box and it worked.
Here is a screenshot of the page I am talking about :
Take the comment from the top line, and instead of auto-detect put the path and put the name convert.
IMAGEMAGICK_BINARY = os.getenv ('IMAGEMAGICK_BINARY', 'C:\Program Files\ImageMagick-7.0.8-Q16\convert.exe')
For windows users,
Change line 54 in config_defaults.py wherever moviepy library is installed
It can be in C:/users/anaconda/lib/site-packages if you are using anaconda
IMAGEMAGICK_BINARY = os.getenv('IMAGEMAGICK_BINARY', 'C:\Program Files\ImageMagick-7.0.11-Q16-HDRI\magick.exe')
will work
I had the same problem and it got fixed thanks to this comment.
from moviepy.config import change_settings
change_settings({"IMAGEMAGICK_BINARY": r"C:\\Program Files\\ImageMagick-7.0.8-Q16\\magick.exe"})
This solved the problem for me.

How to read a chm file from a python code running on windows

I want to know some uses of pychm package :
Is this package useful only on linux
Would it ever be useful for a python program runnning on windows
So if I am writing a python script on windows and if this script must extract information from a chm file, then how do I do it.
I am also trying to install the python chm package on windows to have a better understanding. But When I execute pip install pychm I get the following error :
chm/swig_chm.c(681) : fatal error C1083: Cannot open include file: 'chm_lib.h': No such file or directory
Can someone explain me all these issues. It might be a very trivial query but has been troubling me for quite some time

Categories

Resources