pdfminer - import error - python

I’m new to Python and programming in general.
I am trying to install pdfMiner. I have Windows 7 with Python 2.7 installed.
I followed the instructions when installing (downloaded the PDFMiner source, unpacked it, and ran setup.py to install and it was installed in C:\pdfminer) – no errors.
It created:
build, build\lib,build\lib\pdfminer, then copied files to build\lib\pdfminer. It created build\scripts-2.7 and copied tools\pdf2txt.py, dymppdf.py to scripts, then wrote install-egg-info
and had no errors with install.
When I try running the test document from the command line:
C:\pdfminer\pdfminer-20140328> pdf2txt.py samples/simple1.pdf
I get:
File “C:\Python27\Scripts\pdf2txt.py”, line3, in <module> from pdfminer.pdfdocument import PDFDocument
ImportError: No module named pdfminer.pdfdocument
I saw this post:
pdfminer - ImportError: No module named pdfminer.pdfdocument
and tried following it (#1..put sys.path.append… into pdf2txt.py) and get the same error.
The system variables do include the path (pdfminer\pdfminer-20140328).
I’ve looked for other solutions but haven’t had much luck – the file is there but I can’t seem to get the program to look in the right area for it…I think.
Do I have the wrong path or is it installed in the wrong directory?

Related

cannot import name '_imaging' from 'PIL' error

I am using Pillow-6.1.0 for my python project and I am trying to import the ImageGrab() function inside it however I keep getting this following error:
cannot import name '_imaging' from 'PIL'
I am currently using Python 3.7 and editing the code on Visual Studios (Unsure if the IDE may play part in the error as I do not have much experience on it)
I am also running Windows so some of the solutions I have seen which require Linux does not work for me.
What I have tried:
Uninstalling and reinstalling Pillow
Deleting everything with "PIL" in the Python37-32/Lib/site-packages folder and uninstalling Pillow and reinstalling
Moving the Pillow module directly into my project folder
Moving ImageGrab.py directly into my project folder
Updated my Pillow module
All my reinstallations of Pillow is via the pip command
Other possibly relevant info:
ImageGrab() is not the only module that I cant import, I also cant import the Image module
I can import the PIL module successfully but I cannot access the modules within it via the command "from PIL import some_PIL_module" in my IDE
I only get the "cannot import name '_imaging' from 'PIL'" error when I am running my code through the Visual Studios IDE, if I type the command "from PIL import ImageGrab" directly into the python terminal it runs successfully with no errors
This is the line that gives me the error in my code
from PIL import ImageGrab;
I expected it to import with no problems but instead, I get the following error:
cannot import name '_imaging' from 'PIL'

"cannot import name smbserver" when using impacket with smbrelayx.py

I know this is not an actual info-sec question, but I am having problems with getting the smbrealyx.py module to work. For some reason I get the following error when I try to execute the aforementioned python program.
Traceback (most recent call last):
File "smbrelayx.py", line 43, in <module>
from impacket import smbserver, smb, ntlm, dcerpc, version
File "/usr/lib/python2.7/dist-packages/impacket/smbserver.py", line 18, in <module>
from impacket import smbserver, version
ImportError: cannot import name smbserver
I am not familiar with python programming and I was hoping someone could help me fix this issue.
Looks like you have an old impacket version installed and you are using a newer version of smbrelayx.py.
First of it'd be great to know what version you have. You can easily do that by typing inside a Python interpreter the following:
from impacket import version
print version.BANNER
Assuming you have an old version, first of all it'd be great to remove the existing version. Depending on your Unix distro it might be just as easy as to remove the python-impacket package, or you can manually remove the library files by getting to know where those files are located:
import impacket
print impacket.__file__
That will give you the path where the library is installed. I'd suggest to remove the entire directory.
Now that your system is clean, you have two options:
Install a stable version: Grab the latest stable version from here. Uncompress it in a temp directory and then run:
python setup.py install
That will install the libraries and example scripts (e.g. smbrelayx.py)
Install the development version: You will need to git clone the development version first by running:
git clone https://github.com/CoreSecurity/impacket
Once the repo is cloned, inside the impacket directory type:
python setup.py install
That will install the libraries and example scripts (e.g. smbrelayx.py)

cx_freeze no module named 'pkg_resources'

I'm using Python 3.3.5 with cx-freeze 4.3.3 on windows 8.1.
I'm trying to cx_freeze a program that uses pkg_resources.
I initially had it in my setup file under packages, but when I tried to freeze it the processes stopped with an error Import Error: No module named 'pkg_resources'.
I then moved it in the setup file from packages to includes. The cx_freeze process completed this time but when I tried to start the application I got another error message.
If I go to my IDE and try to import pkg_resources it works fine.
>>> import pkg_resources
>>> pkg_resources
<module 'pkg_resources' from 'C:\\Python33\\lib\\site-packages\\setuptools-18.0.1-py3.3.egg\\pkg_resources\\__init__.py'>
There's a similar question asked here, and the solution is to re-install setuptools. So I downloaded setuptools 18.0.1 and installed it via cmd, but it did not solve my problem and I'm still getting the same errors with cx_freeze.
Any help getting this to work would be greatly appreciated.
Edit: My solution (hack) has been to write the dependency out of yagmail. Yagmail's original _innit__.py...
from pkg_resources import get_distribution
__project__ = 'yagmail'
__version__ = get_distribution(__project__).version
I first put a print statement in there to get the version, and then hard coded it.
__project__ = 'yagmail'
__version__ = '0.4.84'
Though this has solved my problem it isn't really the answer, so will leave this open should someone have a solution that keeps pkg_resources.

StringIO and String Import error on installing VIM-Latex via Pathogen

I tried to install VIM-Latex using the Pathogen plugin on my machine which is running OSX Lion 10.7.5. I copied the downloaded VIM-Latex plugin files into my ~/.vim/bundle directory.
I also edited the .vimrc according to the instructions specified here.
However, I'm getting the following errors on trying to open a tex document in MAC Vim:
File "/Users/username/.vim/bundle/vim-latex-1.8.23-20130116.788-git2ef9956/ftplugin/latex- suite/outline.py", line 12, in <module>
import StringIO
ImportError: No module named StringIO
Error detected while processing /Users/username/.vim/bundle/vim-latex-1.8.23-20130116.788-git2ef9956/ftplugin/latex-suite/main.vim:
and
File "/Users/username/.vim/bundle/vim-latex-1.8.23-20130116.788-git2ef9956/ftplugin/latex-suite/pytools.py", line 1, in <module>
import string, vim, re, os, glob
ImportError: No module named string
Also, I ran a basic python script from the terminal that imported StringIO and string, and both seem to be getting imported just fine.
I'm not sure where the problem is here. Since I'm really new both with VIM and Installing Plugins, I'm not sure how I should go about debugging this issue, and so, any help will be precious!
Thanks!
StringIO and string are not available in Python 3.x. To make this code work, you have to run it with Python 2.x, e.g. Python 2.7.

Python: installing multiprocessing

I need to import the multiprocessing module in Python 2.5.
I've followed the instructions here exactly: http://code.google.com/p/python-multiprocessing/wiki/Install
make and make test run without errors. I've also edited $PYTHONPATH to include the directory where the package is installed.
But 'import multiprocessing' still says: "ImportError: no module named multiprocessing".
What am I doing wrong? Is there some step missing from these instructions? I haven't installed a Python module before.
Navigate to the directory containing the package then type:
python setup.py install
This info was contained in the INSTALL.txt file.
http://code.google.com/p/python-multiprocessing/source/browse/trunk/INSTALL.txt
perhaps you can try:
import sys
sys.path.append('/path/to/processingdotpylibs/')
import processing

Categories

Resources