Hello i am working on a project(converting pdf to jpeg images),i am using the pdf2img module in python for the same.But i am getting an error here:
images=convert_from_path(filename,poppler_path=r'C:\Program Files\Library\bin')
the error which i used to get in the beginning was poppler was not in path,but after correcting it now i am getting the error:
pdf2image.exceptions.PDFPageCountError: Unable to get page count.
Kindly help me to resolve this issue,
from pdf2image import*
the module i used is pdf2image
I had the same issue and solved it by installing Microsoft Visual C++ Redistributable which was missing from my computer (download here). You can check that the program pdfinfo.exe works fine, by running it from your console (the program is located in the Library/bin folder of poppler). If it fails, you will get the real error, otherwise it's caught and silenced by pdf2image.py telling you it could not get the page count.
Haw, I also encountered this problem.
This problem occurs if the script is executed on IDE, If you execute the script in the folder, There will be no problem.
Maybe it's the execution path.
from pdf2image import convert_from_path
images=convert_from_path("pdf_file_path_with_name",poppler_path="")
for i in range(len(images)):
images[i].save('image_name'+ str(i) +'.jpg', 'JPEG')
The reason could be if your PDF file path is not proper or broken. In my problem I solved this by changing quotes to single quote in file path. Maybe this is something related with encoding.
If you dive into pdf2image code, you'll see that this is happening after pdfinfo.exe is called on your pdf file. Try running it manually and you'll see what is happening there and if there any errors while running pdfinfo.exe.
I had this error: "The code execution cannot proceed because freetype.dll was not found...". So I just found freetype.dll in my Anaconda path (I used Anaconda to install pdf2image on Win10) and added this path to PATH environment variable, so it would be found. This was the only problem and I've got my images from pdf.
I encountered the same error but I correct my file path after that the issue will be resolved.
Related
I know it was asked a lot but none helped me.
i have pyinstaller my code into exe file. This works great on my PC but on others it generates FATAL ERROR - cannot execute script.
Than - execute from other PC with command line to see what the issue is and it is breaking on below :
_tkinter.TclError: bitmap "C:/LOG_29710.ico" not defined
This is the full path on my local PC but it seems to search for the icon in other PC same path which of course not exist.
What am I missing here?
by the way i have several images (not icons) with same path and same errors for all...I guess I need somekind of relative path or maybe put all of them in a specific place...
You found the reason your self:
This is the full path on my local PC but it seems to search for the icon in other PC same path which of course not exist. What am I missing here?
If the file isn't there, it can't be found. So put it there or, if you copied the whole project with icon to another PC, then make the path relative, so it can be found.
If the icon is in the same folder as the project, use:
"LOG_29710.ico" instead of full path "C:\LOG..."
This is the code I am primarily trying to get to work. It runs fine when I run it in Spyder (Python 3.8). However when running the .bat file I get the following error message.
urllib3.exceptions.SSLError: Can't connect to HTTPS URL because the SSL module is not available.
I also tried running a less complex piece of code that also doesn't work, its error message is as follows. (This now works, see below)
ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found.
My code for the .bat files are as follows (I think my .bat file code is fine, as one of them now runs perfectly, so it's not a path issue):
C:\Users\Thomas\Desktop\Coding\Python\Chess_Files>"C:\Users\Thomas\Anaconda3\python.exe" "C:\Users\Thomas\Desktop\Coding\Python\Python_Code\lichessAPI.py"
C:\Users\Thomas\Desktop\Coding\Python\Chess_Files>"C:\Users\Thomas\Anaconda3\python.exe" "C:\Users\Thomas\Desktop\Coding\Python\Python_Code\planetorbits.py"
UPDATE:
I was able to get the second .bat file of code to work, by uninstalling and reinstalling both numpy and matplotlib using pip. However, the first .bat file is still running into the same error.
It has been suggested that I install openSSL, I'm not sure what that even is and why I can't just use urllib3 seeing as that works when I run the code myself in anaconda.
FINAL UPDATE:
I have found a solution and posted it below. Hope this helps.
I was able to solve the issue by following advice from Matt Dnv:
Requests (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.") Error in PyCharm requesting website
I copied and pasted the following:
libcrypto-1_1-x64.*
libssl-1_1-x64.*
from D:\Anaconda3\Library\bin to D:\Anaconda3\DLLs
I'm using VScode for my python project on macOS, but I cannot use the function of go to definition and can not open file in PROBLEMS.
For example:
when I control-click (macOS) and select go to definition, it raise a warning like this:
Unable to open 'spider.py': A system error occurred (ENOTDIR: not a directory, stat '/Users/gassy/Documents/python_spider/toutiao/spider.py/Users/gassy/Documents/python_spider/toutiao/spider.py').
Also, when I click an entry listed in PROBLEMS, it also give the same error:
It seems like a problem creating the path to the file as the path is repeated in the error message like path/to/file.py/path/to/file.py
Go to Definition works for global variables.
System: macOS Mojave
Version: VScode 1.30.2
You can install the extension pydev in vscode.
The extension website is https://marketplace.visualstudio.com/items?itemName=fabioz.vscode-pydev
If you using Python3, Please visit the official website
http://www.pydev.org/vscode/
Finally ,I find the reason!
I thought this bug may be produced by an extension, so I reinstalled VScode for many times followed the method of this website
uninstall-remove-vscode-mac
and tried to find the reason.
When I install Visual Studio IntelliCode, it ask me to install Microsoft Python Language Server. After that, this bug happened.
Hope this solution will help you.
The same problem happened to me.
And it turn out to be the Chinese path that caused this problem.
Copy the folder to a path that contains no Chinese character, and things work well for me
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.
I made a simple hello program using Sublime Text. Run it using windows powershell but everytime I am getting error like :
C:\Python27\python.exe: can't find '__main__' module in 'X'
X is the name of folder. I have Python 2.7.4 Installed. How to fix it?
Maybe there's something wrong with your C:\Python27\python.exe.
See if there are two python under the folder C:\Python27:
python.exe
python2.7.exe.
If so, chose the python2.7.exe
Also possible if your module X is in anaconda or something similar, then you should adjust your Sublime environment to include anaconda (or whatever you're using).
Tools -> Build System -> New Build System
I know nothing about Python, other than running other people's Python apps on Windows occasionally. I see that this is an old thread, but still ran into this just now--the app threw this error and wouldn't run at all unless I included the '.py' extension on the command line.
This error can be caused by file corruption -- check that your module 'X' was copied correctly to the destination folder -- try opening it in an editor and make sure it looks ok. You will get this same error if you try to run Python on a file which is not a text file or a precompiled python module.
This problem is the same what I get last night, if you are using PyCharm to code Python, you can re-check the existing configuration, make sure in the working directory section it is filled in, and in the script path section, it is the same as the file location and file name.
Actually this is a problem where you have to write down the correct storage place.