Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix slate for Python 3.4+ #32

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Fix slate for Python 3.4+ #32

wants to merge 10 commits into from

Conversation

rtouze
Copy link

@rtouze rtouze commented May 30, 2016

I faced some issues while using slate with Python 3.4 and 3.5. It is due to the differences in relative import between python 2 and python 3 which lead to an error in classes.py.

I also updated the tests, the readme and setup.py.

I did not take time to test with Python 2.7 and Python 3 releases prior 3.4 though.

I hope you'll be able to merge. BTW, thanks for your work on this lib!

@mvherweg
Copy link

mvherweg commented Jun 6, 2016

import slate fails for me because it cannot import utils.
change import utils in classes.py with from slate import utils and then it worked for me.

@benjaminweb
Copy link

Fixes #5 dating back August 5, 2014.
#24 is a duplicate of #5.
PR #33 is a duplicate of this PR, the present PR seems but more comprehensive (untested by me).

if PYTHON_3:
import slate.utils as utils
else:
import utils

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bad way to fix the problem. Just use from . import utils, which works on both versions of python

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Thanks for the review.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your latest patch has an extra space, but otherwise looks good to me

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talking about extra spaces, I can fix some style issues in classes.py using pycodestyle. Is it OK for you?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... it goes beyond the scope of this PR though

@aron-bordin
Copy link

Hi ! any update on this? I'm facing problems while installing on python 3.6

@zlqs1985
Copy link

zlqs1985 commented Aug 9, 2017

I import slate in anaconda python 3.5 environment, with the slate and pdfminer.six package have been installed. Then the following ImportError emerged, so how can I fix it?
--updates-- even under python 2.7 , the error remains

import slate
Traceback (most recent call last):

  File "<ipython-input-2-6c5d1974407e>", line 1, in <module>
    import slate

  File "C:\Users\zhanglu\Anaconda3\lib\site-packages\slate\__init__.py", line 48, in <module>
    from slate import PDF

ImportError: cannot import name 'PDF'

@jangdan
Copy link

jangdan commented Feb 12, 2018

Adding to what @benjaminweb said, #26 and #29 also fix the same import utils issue fixed here.

@jangdan
Copy link

jangdan commented Feb 14, 2018

This PR has some problems, too; read along...

So I'm trying to try out various Python (Python 3) PDF handling libraries, but slate was too good for me to try out the other ones. Of course, except for the fact that it didn't work with Python 3.6. I am on the latest macOS, using the latest (as of today) Python 3.6.4.

I tried installing slate the normal way through pip, but , as already mentioned in #38, I ran into a setup.py error:

Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/g6/x78ww6cx6mb_q6ws9_c24xkr0000gp/T/pip-build-v99m2lqm/distribute/

I tried installing the repo directly as @karoldvl in #38 had mentioned, but to no avail, resulting in the same dependency error.

I went through all the issues and PRs present in the repo, and this PR seemed to be the most active, most recently. So I went ahead and tried it, but I ended up with the same error as before. I can't tell if @aron-bordin is mentioning the same issue, but hope this helps.

Then I found a fork of @rtouze's fork(!), here. And interestingly this one fixes the damn setup.py error. Yey. I can clarify that my Python scripts are now pumping out pages and pages of scraped PDFs to the console.

I would suggest that @rtouze, one way or another, apply the changes in the @alkivi-sas repo.

Until then, running

pip install https://github.com/alkivi-sas/slate/tree/python3

installs a working fork of slate (currently).

Cheers.

setup.py Outdated
@@ -23,7 +23,7 @@
packages=find_packages('src'),
package_dir={'': 'src'},
requires=[pdfminer],
install_requires=['distribute', pdfminer],
install_requires=[pdfminer],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, I had no idea timClicks/slate had a fix for this issue already—link—I see now that this causes conflicts. 'setuptools' should be used; though I don't think this is an urgent problem.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I let the people in charge of the project choose the right solution :-)

@jangdan
Copy link

jangdan commented Jan 13, 2021

@rtouze: Reasons for closing?

@rtouze
Copy link
Author

rtouze commented Jan 18, 2021

@rtouze: Reasons for closing?

I opened this 4 years ago... Is the project still maintained?

@rtouze rtouze reopened this Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants