iSarabjitDhiman / TweeterPy

TweeterPy is a python library to extract data from Twitter. TweeterPy API lets you scrape data from a user's profile like username, userid, bio, followers/followings list, profile media, tweets, etc.
MIT License
123 stars 17 forks source link

Error in demjson setup command: use_2to3 is invalid. #27

Closed codilau closed 10 months ago

codilau commented 10 months ago

Hi, congrats on the constant improvements to this great module. I pip install often in new venvs so I could observe that that version is not the latest (quite obsolete at this point). What's the best approach, other than manually updating to the latest commits? Thanks

iSarabjitDhiman commented 10 months ago

I am not sure why you are getting an older version, maybe pip is trying to install the version stored in cache memory. I uploaded the latest version on pypi(pip) yesterday. So the git and pypi version are the same as of now.

Try this :


pip install tweeterpy --upgrade --no-cache-dir

Let me know how it goes.

fpmirabile commented 10 months ago

I'm able to download it, but on MAC getting the following error

Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error in demjson setup command: use_2to3 is invalid.
      [end of output]

Do we need to use setuptools < v 58 ?

codilau commented 10 months ago

@iSarabjitDhiman, as @fpmirabile noticed, I'm getting a similar error on --no-cache-dir option:

pip install tweeterpy --upgrade --no-cache-dir Collecting tweeterpy Downloading tweeterpy-1.0.1-py3-none-any.whl (19 kB) Requirement already satisfied: requests==2.31.0 in ./.venv/lib/python3.10/site-packages (from tweeterpy) (2.31.0) Requirement already satisfied: soupsieve==2.4.1 in ./.venv/lib/python3.10/site-packages (from tweeterpy) (2.4.1) Collecting demjson==2.2.4 Downloading demjson-2.2.4.tar.gz (131 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 131.5/131.5 KB 2.0 MB/s eta 0:00:00 Preparing metadata (setup.py) ... error error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [1 lines of output] error in demjson setup command: use_2to3 is invalid. [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed

× Encountered error while generating package metadata. ╰─> See above for output.

iSarabjitDhiman commented 10 months ago

I'm able to download it, but on MAC getting the following error

Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error in demjson setup command: use_2to3 is invalid.
      [end of output]

Do we need to use setuptools < v 58 ?

hey @fpmirabile @codilau

I guess this is some issue with the new library (demjson) I added to TweeterPy.

Manually install setuptools version 57.5.0

pip install setuptools==57.5.0

It should solve the issue.

Keep me posted.

duplicate : #28

codilau commented 10 months ago

@iSarabjitDhiman installing setuptools as you mentionned cleared the error on pip install tweeterpy --upgrade --no-cache-dir.

codilau commented 10 months ago

Just for the record, is this why pip install is delivering an outdated version?

fpmirabile commented 10 months ago

I'm trying to downgrade python to 3.10. I'll keep you posted after I test that (I was working with 3.11 in my env)

iSarabjitDhiman commented 10 months ago

Thanks for the update @codilau, @fpmirabile

No, the above error has nothing to do with the outdated versions on pip. The reason you were getting the outdated version is cache memory. Adding these two flags --upgrade --no-cache-dir should solve the issue.

The setuptools solution is for demjson package (for the following error).

Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      error in demjson setup command: use_2to3 is invalid.
      [end of output]
iSarabjitDhiman commented 10 months ago

@fpmirabile , you don't need to downgrade python.

Try installing the previous version

pip install tweeterpy==1.0.0

If it works, then its demjson package which is causing the issue. I just added it in the most recent commit.

fpmirabile commented 10 months ago

@iSarabjitDhiman I did it with python 3.10 (I can check with 3.11) In conda, I do not get errors and seems to be working well.

Since I rollback my conda env, I had to install lxml

iSarabjitDhiman commented 10 months ago

Alright @fpmirabile So it's working now, right? Or you still having issues with a specific version of python? Once you have tested it on different envs, please let me know.

Thanks.

fpmirabile commented 10 months ago

It is working now!

pip install tweeterpy==1.0.0

That fixed the issue, let me know if you did some changes I can try again with newer version

iSarabjitDhiman commented 10 months ago

It is working now!

pip install tweeterpy==1.0.0

That fixed the issue, let me know if you did some changes I can try again with newer version

So I was right. The issue is related to the demjson library which I used in 1.0.1 version (the most recent one).

I replaced js2py library with demjson as it was a bit slow while parsing javascript object. But this newly added demjson library has installation issues which can be solved by installing pip install setuptools==57.5.0 Umm, either I am gonna have to find some other alternate to parse javascript object (convert javascript object to python dict) or roll back to js2py package(its a bit slow).

I also checked chompjs its perfect and the fastest one out there. But it has installation issues on windows.

I am open to suggestions.

duplicate : #28

fpmirabile commented 10 months ago

I'd continue with demjson but force the setuptools to be < 58...

I honestly don't know others libraries. I'm not the best python dev out there

iSarabjitDhiman commented 10 months ago

I believe you can update the setuptools to the latest version or <58 , once TweeterPy is installed. Try it and provide feedback, others can use your help. Thanks.

codilau commented 10 months ago

@iSarabjitDhiman, update and a suggestion. The demjson library still causes errors - in some cases even if installing setuptools < 58 prior. May I suggest using demjson3? It's a fork specifically designed for Python3 so it will not cause the error in that use_2to3 function. You use that on only 1 line and it should do the same job in the same way.

iSarabjitDhiman commented 10 months ago

@iSarabjitDhiman, update and a suggestion. The demjson library still causes errors - in some cases even if installing setuptools < 58 prior. May I suggest using demjson3? It's a fork specifically designed for Python3 so it will not cause the error in that use_2to3 function. You use that on only 1 line and it should do the same job in the same way.

wait there is demjson3? I have been looking for a alternative for so long. Could u please attach the link to their github or pypi page?

Edit : Found it (You can still attach links to demjson3 for future reference). Its amazing. Just installed it and working smoothly. Going to commit changes. Thanks very much for your help. @codilau

codilau commented 10 months ago

@iSarabjitDhiman, thank you for your amazing work!