pgaref / HTTP_Request_Randomizer

Proxying Python Requests
http://pgaref.com/blog/python-proxy/
MIT License
151 stars 59 forks source link

Library not found error #10

Closed ieguiguren closed 7 years ago

ieguiguren commented 8 years ago

I launch the script from the 'proxy' subdirectory in GNU/Linux. This causes to get the following error: [~/dev/HTTP_Request_Randomizer/project/http/requests/proxy]>python requestProxy.py Traceback (most recent call last): File "requestProxy.py", line 1, in from project.http.requests.parsers.freeproxyParser import freeproxyParser ImportError: No module named project.http.requests.parsers.freeproxyParser

to solve it, I had to add the project's directory to the path: +import sys +import os +sys.path.insert(0, os.path.abspath('../../../../'))

I didn't want to push it but, as long as the lines remain when I pushed the commit, I'd rather explain why they are there. How do you call the script to avoid having to add these lines?

pgaref commented 8 years ago

Usually I am using an IDE but I will take a look at it.

skalayilg commented 7 years ago

i am getting error while importing the package

from http.requests.proxy.requestProxy import RequestProxy Traceback (most recent call last): File "", line 1, in ImportError: No module named 'http.requests'

gg4u commented 7 years ago

Same here, python3

from http.requests.proxy.requestProxy import RequestProxy Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'http.requests'

pgaref commented 7 years ago

Hello there,

It looks to me that requests library in not installed. Did you try pip install -r requirements.txt before that? PS: Several proxy providers changed their website layout recently cause some parsers to fail, will have to take a look at that in a few days.

Cheers, Panagiotis

christinabo commented 7 years ago

Hello,

I am using Python 3.5.2 and I am getting the same error

from http.requests.proxy.requestProxy import RequestProxy ImportError: No module named 'http.requests'

After some time I realized that there is another built-in module called 'http' and seems that the script is trying to import from this one. This is why it can't find it. However, trying in Python27 perfectly works, as the built-in 'http' module was previously named 'httplib'.

I tried to force the import from my 'site-packages' folder where the module is, using this way:

site_packages = [p for p in sys.path if 'site-packages' in p]
print(site_packages)
for site_pack in site_packages:
    try:
        spec = importlib.util.spec_from_file_location\
            ('RequestProxy',
            site_pack + '\\http\\requests\\proxy\\requestProxy.py')
        randomiz = importlib.util.module_from_spec(spec)
        spec.loader.exec_module(randomiz)
        break
    except FileNotFoundError:
        continue

It works for the file that tries to call the module, however it crashes again when it comes to the inner imports of the sub-modules. Is there any pythonic way to overpass this conflict and make my script look into the right module?

Any help is appreciated. Thanks!

Christina

pgaref commented 7 years ago

Hello there, Thanks for reaching out! @christinabo the error was produced by a naming conflict with and requests library and python3. The project was mainted under python 2.7.9 so I was never really aware of the issue. Good news is I just released version 1.0.1 which solves the issue (had to rename the package). Testing the code both with Tox and Travis yields no errors.

Please give it a try and let me know!

Panagiotis

christinabo commented 7 years ago

Hello Panagiotis,

Thank you very much for updating the project! However, I am getting this error when trying to install it:

Complete output from command python setup.py egg_info: warning: pypandoc module not found, could not convert Markdown to RST Traceback (most recent call last): File "", line 1, in File "C:\bla\bla\http-request-randomizer\setup.py", line 62, in long_description=read_md('README.md'), File "C:\bla\bla\http-request-randomizer\setup.py", line 14, in read_md = lambda f: open(f, 'r').read() FileNotFoundError: [Errno 2] No such file or directory: 'README.md'

After installing the pypandoc module (although it is just a warning), I get the following error:

Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 1, in File "C:\bla\bla\http-request-randomizer\setup.py", line 62, in long_description=read_md('README.md'), File "C:\bla\bla\http-request-randomizer\setup.py", line 11, in read_md = lambda f: convert(f, 'rst') File "C:\Python36\lib\site-packages\pypandoc__init__.py", line 66, in convert raise RuntimeError("Format missing, but need one (identified source as text as no " RuntimeError: Format missing, but need one (identified source as text as no file with that name was found).

Am I missing something?

Thank you a lot.

Best, Christina

pgaref commented 7 years ago

Hello @christinabo ,

Thanks for reporting the issue - pypandoc was redundant, just causing trouble. I had to remove it and release a new version with the fix.

Please try again using the latest library version (1.0.3)

Cheers, Panagiotis

christinabo commented 7 years ago

Hello @pgaref, thanks for the quick response and fix! I have successfully installed the project.

However, some minor changes needed in order to compile and run it on Python3 environment (and at the same time on Python2 of course). I made these changes and created a pull request, in case you want to integrate them.

Have a nice weekend, Christina

pgaref commented 7 years ago

@christinabo thanks for the PR, your patch is now merged!

I consider the issue now solved! Thanks everyone for reporting and contributing 👍

Panagiotis

christinabo commented 7 years ago

Hello @pgaref,

I was using the package without any problems until I installed it on another machine. The module exits with error for the print statement

print 'RR Status {}'.format(request.status_code) ^ SyntaxError: invalid syntax

which I had previously transformed into a function on my commit. After downloading the code as a tar from here https://pypi.python.org/pypi/http-request-randomizer and checking the code, it seems that my changes for python3 compatibility are not there, although I can see them on GitHub. So, I cannot run the package again! :) Are these changes removed or something else is going on?

Thank you, Christina

pgaref commented 7 years ago

Hello @christinabo ,

The plan was to have the next code release with some new features but they are not there yet. I just release your fixes with some other minor commits. Please check the latest version now: https://pypi.python.org/pypi/http-request-randomizer

PS: I guess you can always install the latest dev version downloading the repo and setup.py install

Cheers, Panagiotis