PyPDF2 giving me an invalid argument error - pypdf

I'm trying to parse text from pdf file. while I was doing tutorial of how to PyPDF2 I got the following error. I did the search for an answer but ended up finding none. Any Help will be greatly appreciated.
Traceback (most recent call last):
File "D:/text_recognizer/main.py", line 4, in <module>
inputStream = PyPDF2.PdfFileReader(input)
File "D:\KimKanna's Class\python27\lib\site-packages\PyPDF2\pdf.py", line 1084, in __init__
self.read(stream)
File "D:\KimKanna's Class\python27\lib\site-packages\PyPDF2\pdf.py", line 1689, in read
stream.seek(-1, 2)
IOError: [Errno 22] Invalid argument
here is fullcode
import PyPDF2
with open(".\\pdf\\test_sample.pdf","rb") as input:
inputStream = PyPDF2.PdfFileReader(input)

In my case the .pdf I wanted to open is empty and not closed from previous python code in powershell(cmd prompt). So, when I tried to delete those files it says 'Close the file and try again'. (that was my "AHaa" moment)
So I stopped the py.exe from my Windows task manager and deleted those empty, not closed files. Then I run the same code with another files, It worked fine.. :)

Related

Giant IPKernelApp Error Using Hydrogen in Atom

Starting a few days ago, after months without issue, I began having a giant error box keep popping up when editing my code in Atom. I believe it is from the Hydrogen plugin, the weird thing is even with this error the code still runs and does what I want it too.
I created a new conda environment, installing only what I needed (pandas, geopandas, descartes, jupyter) and even when using the new environment in Atom I am getting this issue. I've tried upgrading ipykernel but it is already the most recent version.
Error Message
[IPKernelApp] ERROR | Exception in message handler: Traceback (most recent call last): File "/home/username/anaconda3/envs/fresh/lib/python3.8/site-packages/ipykernel/kernelbase.py", line 268, in dispatch_shell yield gen.maybe_future(handler(stream, idents, msg)) File "/home/username/anaconda3/envs/fresh/lib/python3.8/site-packages/tornado/gen.py", line 762, in run value = future.result() File "/home/username/anaconda3/envs/fresh/lib/python3.8/site-packages/tornado/gen.py", line 234, in wrapper yielded = ctx_run(next, result) File "/home/username/anaconda3/envs/fresh/lib/python3.8/site-packages/ipykernel/kernelbase.py", line 583, in complete_request matches = yield gen.maybe_future(self.do_complete(code, cursor_pos)) File "/home/username/anaconda3/envs/fresh/lib/python3.8/site-packages/ipykernel/ipkernel.py", line 360, in do_complete return self._experimental_do_complete(code, cursor_pos) File "/home/username/anaconda3/envs/fresh/lib/python3.8/site-packages/ipykernel/ipkernel.py", line 385, in _experimental_do_complete completions = list(_rectify_completions(code, raw_completions)) File "/home/username/anaconda3/envs/fresh/lib/python3.8/site-packages/IPython/core/completer.py", line 484, in rectify_completions completions = list(completions) File "/home/username/anaconda3/envs/fresh/lib/python3.8/site-packages/IPython/core/completer.py", line 1818, in completions for c in self._completions(text, offset, _timeout=self.jedi_compute_type_timeout/1000): File "/home/username/anaconda3/envs/fresh/lib/python3.8/site-packages/IPython/core/completer.py", line 1861, in _completions matched_text, matches, matches_origin, jedi_matches = self._complete( File "/home/username/anaconda3/envs/fresh/lib/python3.8/site-packages/IPython/core/completer.py", line 2029, in _complete completions = self._jedi_matches( File "/home/username/anaconda3/envs/fresh/lib/python3.8/site-packages/IPython/core/completer.py", line 1373, in _jedi_matches interpreter = jedi.Interpreter( File "/home/username/anaconda3/envs/fresh/lib/python3.8/site-packages/jedi/api/init.py", line 725, in init super().init(code, environment=environment, TypeError: init() got an unexpected keyword argument 'column'
The latest jedi (0.18) release is incompatible with IPython 7.19 see this discussion. IPython: 7.20 (released Feb 1st 2020) and 8.0 (not yet released) have a compatibility fix.
The correct workaround at this time is to upgrade IPython:
pip install -U ipython==7.20
In future you can search for the final two lines of the trackback after removing all path fragments specific to your installation, this is searching for:
line 2029, in _complete completions = self._jedi_matches IPython/core/completer.py, line 1373, in _jedi_matches interpreter = jedi.Interpreter( jedi/api/init.py, line 725, in init super().init(code, environment=environment, TypeError: init() got an unexpected keyword argument 'column'
This will give you the relevant issues on GitHub in the first two Google result as for today.

Error encountered when using Autodock/Vina Plugin in PyMOL

I am a beginner to PyMOL and I am using it for my docking project. I have encountered errors using the Autodock/Vina plugin in PyMOL.
I was trying to carry out the set up for the grid and Error 1 occurred when I was clicking on the arrow that allows me to change the grid parameter x,y and z.
As for Error 2, it occurs when I tried to generate the receptor on the next page.
Under the log section, I also got a notice saying "Batch: prepare_receptor4.py -r C:\Users\User\Desktop\plugin-test\receptor.3ig7.pdb -o C:\Users\User\Desktop\plugin-test\receptor.3ig7.pdbqt -A checkhydrogen"
It would be appreciated if you would tell me what is missing or should be done to solve these errors.
I look forward to reading any of your replies and I thank you in advance,
Elayne
Error: 1
TypeError Exception in Tk callback
Function: <bound method Autodock.n_points_Y_changed of <pmg_tk.startup.autodock_plugin.Autodock object at 0x0000020649CD9388>> (type: <class 'method'>)
Args: ('scroll', '1', 'units')
Traceback (innermost last):
File "C:\Users\User\AppData\Local\Schrodinger\PyMOL2\lib\site-packages\Pmw.py", line 1823, in __call__
return self.func(*args)
TypeError: n_points_Y_changed() takes 2 positional arguments but 4 were given
Error: 2
FileNotFoundError Exception in Tk callback
Function: <bound method Autodock.generate_receptor of <pmg_tk.startup.autodock_plugin.Autodock object at 0x0000020649CD9388>> (type: <class 'method'>)
Args: ()
Traceback (innermost last):
File "C:\Users\User\AppData\Local\Schrodinger\PyMOL2\lib\site-packages\Pmw.py", line 1823, in __call__
return self.func(*args)
File "C:\Users\User\AppData\Local\Schrodinger\PyMOL2\lib\site-packages\pmg_tk\startup\autodock_plugin.py", line 1940, in generate_receptor
result, output = getstatusoutput(command)
File "C:\Users\User\AppData\Local\Schrodinger\PyMOL2\lib\site-packages\pmg_tk\startup\autodock_plugin.py", line 85, in getstatusoutput
p = Popen(args, stdout=PIPE, stderr=STDOUT, stdin=PIPE, env=env)
File "C:\Users\User\AppData\Local\Schrodinger\PyMOL2\lib\subprocess.py", line 800, in __init__
restore_signals, start_new_session)
File "C:\Users\User\AppData\Local\Schrodinger\PyMOL2\lib\subprocess.py", line 1207, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
I'm also encountering the same issue on Windows, try running a linux distro on vmware and make sure to install Pymol with support for Python 2.7 because the script is not compatible with Python3.

pydev debugger fails on launch but code runs fine

When I launch the pydev debugger with LiClipse (latest versions of both) I get a "KeyError:" exception.
I have ensured that the workspace folder has the proper permissions. I get this problem even if I run LiClipse in Administrator mode.
I expect to be able to debug my python code. My actual results are the following errors:
pydev debugger: starting (pid: 15388)
Traceback (most recent call last):
File "C:\Program Files\Brainwy\LiClipse 5.2.4\plugins\org.python.pydev.core_7.2.1.201904261609\pysrc\pydevd_file_utils.py", line 487, in _original_file_to_client
return cache[filename]
KeyError: 'c:\\users\\xyz\\my documents\\liclipse workspace\\xyzjirabot\\xyzjirabot.py'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files\Brainwy\LiClipse 5.2.4\plugins\org.python.pydev.core_7.2.1.201904261609\pysrc\_pydevd_bundle\pydevd_net_command_factory_xml.py", line 197, in make_thread_stack_str
py_db, curr_frame, frame_id_to_lineno
File "C:\Program Files\Brainwy\LiClipse 5.2.4\plugins\org.python.pydev.core_7.2.1.201904261609\pysrc\_pydevd_bundle\pydevd_net_command_factory_xml.py", line 170, in _iter_visible_frames_info
filename_in_utf8 = pydevd_file_utils.norm_file_to_client(abs_path_real_path_and_base[0])
File "C:\Program Files\Brainwy\LiClipse 5.2.4\plugins\org.python.pydev.core_7.2.1.201904261609\pysrc\pydevd_file_utils.py", line 489, in _original_file_to_client
translated = _path_to_expected_str(get_path_with_real_case(_AbsFile(filename)))
File "C:\Program Files\Brainwy\LiClipse 5.2.4\plugins\org.python.pydev.core_7.2.1.201904261609\pysrc\pydevd_file_utils.py", line 196, in _get_path_with_real_case
return _resolve_listing(drive, iter(parts))
File "C:\Program Files\Brainwy\LiClipse 5.2.4\plugins\org.python.pydev.core_7.2.1.201904261609\pysrc\pydevd_file_utils.py", line 159, in _resolve_listing
dir_contents = cache[resolved_lower] = os.listdir(resolved)
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\xyz\\My Documents'
While I was posting this question I noticed that there is a capitalization difference with the file name being used as the key and the actual file path. I moved the workspace to the root of my C Drive and that seems to have fixed the problem.
I think it's the spaces in the filename. I moved it to \Users\kieveli\Source\LiClipseWorkspace\ and everything worked correctly.
Had the same issue - Path was set to "..\My Documents" instead of just "..\Documents". Changing the workspace to another directory fixed the problem

sublime text 2 phpcs plugin python error

I am using Sublime Text 2 with some plugins. I can't seem to work with the Phpcs plugin, because after saving the file, it gives me an ugly error:
Writing file /Applications/XAMPP/xamppfiles/htdocs/myProject/application/libraries/Authentication.php with encoding UTF-8
Exception in thread Thread-15:
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py", line 532, in __bootstrap_inner
self.run()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/threading.py", line 484, in run
self.__target(*self.__args, **self.__kwargs)
File "./phpcs.py", line 398, in run
File "./phpcs.py", line 128, in get_errors
File "./phpcs.py", line 194, in execute
File "./phpcs.py", line 197, in parse_report
File "./phpcs.py", line 149, in shell_out
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 623, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1141, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
I have also tried to look into the respective files, but I don't know python at all so I don;t know what to do :-/
Could You please help ?
I ended up using SublimeLinter plugin that provides the showing-potential-errors feature that I wanted from the phpcs plugin.
The plugin is located in THIS GITHUB REPO.
Hope this helps anybody who is having a problem using the phpcs library.
#daniel: Thanks for help

Doxyclean Error

I'm trying to run doxyclean but can't get it to work, any help would be appreciated...
I'm running from terminal :
./doxyclean.py --input=./xml/ --output=./clean/ --name="MyProject" --phone -v
I have my doxygen xml in the folder xml, in the same directory as doxyclean.py
The result is :
Checking arguments
Cleaning XML files:
Traceback (most recent call last):
File "./doxyclean.py", line 1220, in <module>
sys.exit(main())
File "./doxyclean.py", line 1171, in main
cleanXML(filePath, xmlOutputDirectory)
File "./doxyclean.py", line 93, in cleanXML
if not fileIsDocumented(filePath):
File "./doxyclean.py", line 62, in fileIsDocumented
originaldoc = minidom.parse(filePath)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xml/dom/minidom.py", line 1918, in parse
return expatbuilder.parse(file)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xml/dom/expatbuilder.py", line 924, in parse
result = builder.parseFile(fp)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/xml/dom/expatbuilder.py", line 207, in parseFile
parser.Parse(buffer, 0)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 17, column 155
thanks
did you try other ways, my suggestions
use different version of doxyclean
change the arguments to different style, maybe give full paths to the folders.
./doxyclean.py -i Users/xxx/doxyclean/xml/ -o ./clean/ -p
regenerate xml from doxygen
doxyclean works fine. I got this error too and I tried my suggestion 2 and it worked.