Pip cannot install Twint

Hello
I tried to install Twint by pip in Visual Studio Code Terminal, but the following error occurred. Would you help me?

note: This error originates from a subprocess, and is likely not a problem with pip. **
** ERROR: Failed building wheel for cchardet

** Running setup.py clean for cchardet**
Failed to build cchardet
ERROR: Could not build wheels for cchardet, which is required to install pyproject.toml-based projects.

The whole text of error is:

Building wheel for cchardet (setup.py) … error
error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [11 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-cpython-311
creating build\lib.win-amd64-cpython-311\cchardet
copying src\cchardet\version.py → build\lib.win-amd64-cpython-311\cchardet
copying src\cchardet_init_.py → build\lib.win-amd64-cpython-311\cchardet
running build_ext
building ‘cchardet._cchardet’ extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools”: Microsoft C++ Build Tools - Visual Studio
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for cchardet
Running setup.py clean for cchardet
Failed to build cchardet
ERROR: Could not build wheels for cchardet, which is required to install pyproject.toml-based projects.

This is reason why and the error tells you what to do.
Have you install the C++ compiler as it says to do?

Oh, I have ‘Microsoft Visual C++’ version 12.0.4 installed as Control Panel shows, not 14.0.
I will install the new version.
Thank you very much Barry.

Barry;
I installed Microsoft Visual C++ 2015-2022 -14.38.33130 but the following error is still there. Did I do anything wrong?

error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [11 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-cpython-311
creating build\lib.win-amd64-cpython-311\cchardet
copying src\cchardet\version.py → build\lib.win-amd64-cpython-311\cchardet
copying src\cchardet_init_.py → build\lib.win-amd64-cpython-311\cchardet
running build_ext
building ‘cchardet._cchardet’ extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with “Microsoft C++ Build Tools”: Microsoft C++ Build Tools - Visual Studio
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for cchardet
Running setup.py clean for cchardet
Failed to build cchardet
ERROR: Could not build wheels for cchardet, which is required to install pyproject.toml-based projects

Usually, if you’re on Windows and pip resorts to trying to build wheels by compiling, you’re in trouble on a couple of levels. One: the project hasn’t released wheels for the Python version you’re using. That can be normal if a new major version has just released (these days that usually happens in October of each year); you can often get by running the previous version of Python until the project catches up. That’s not the story here (see below). Two: many of the setups to build a particular project are more than just “make sure the compiler is installed”. Project web pages often have more info, there may be other things to install and various setup to do.

The project you’re getting complaints about, cchardet, doesn’t seem to be releasing wheels any longer. You can always check on the PyPI page:

This project hasn’t released since 2020, and the highest listed Python version is 3.9, which you’ll also see in the list of downloadable files.

The project you asked to install, twint, also isn’t receiving new releases, and only claims support through Python 3.8. The project page admits to some installation problems and suggests an alternative approach, and there have been no commits since then. Wouldn’t be getting hopes up about this working out.

1 Like

Dear Mats
I am beginner in Python. Would you tell me what should I do step by step to install twint?
I need twint to count my tweets period of a time.

You should use an older version of Python (3.8), because newer versions are not supported by the library you want to use. And you should be aware that this version of Python will, itself, stop being supported in less than a year. So maybe you better look for a different library to solve the problem, or ask the library author (use the issue system on GitHub) if support can be extended for newer versions of Python.

Finally, you should keep in mind that Twitter - the website, itself - will also change over time. This can cause libraries to break.

Karl
Thank you very much for your explanation.
So I will install Python 3.8 in an Virtual Env and text it. I hope it works.

Dear Carl
I have installed Python 3.6 as the Requirements advices here: GitHub - twintproject/twint: An advanced Twitter scraping & OSINT tool written in Python that doesn't use Twitter's API, allowing you to scrape a user's followers, following, Tweets and more while evading most API limitations..
So I tried to install Twint via pip, but it could not do it again and following message appeared:

Downloading https://files.pythonhosted.org/packages/62/d5/5f610ebe421e85889f2e55e33b7f9a6795bd982198517d912eb1c76e1a53/pycparser-2.21-py2.py3-none-any.whl (118kB)
    100% |████████████████████████████████| 122kB 70kB/s
Installing collected packages: charset-normalizer, idna, idna-ssl, asynctest, frozenlist, attrs, aiosignal, async-timeout, multidict, yarl, aiohttp, pycparser, cffi, pycares, aiodns, soupsieve, beautifulsoup4, cchardet, certifi, urllib3, dataclasses, elastic-transport, elasticsearch, 
pysocks, pytz, six, python-dateutil, numpy, pandas, python-socks, aiohttp-socks, schedule, geogException:
Traceback (most recent call last):
  File "c:\program files\python36\lib\site-packages\pip\basecommand.py", line 215, in main     
    status = self.run(options, args)
  File "c:\program files\python36\lib\site-packages\pip\commands\install.py", line 342, in run 
    prefix=options.prefix_path,
  File "c:\program files\python36\lib\site-packages\pip\req\req_set.py", line 784, in install  
    **kwargs
  File "c:\program files\python36\lib\site-packages\pip\req\req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "c:\program files\python36\lib\site-packages\pip\req\req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "c:\program files\python36\lib\site-packages\pip\wheel.py", line 345, in move_wheel_files
    clobber(source, lib_dir, True)
  File "c:\program files\python36\lib\site-packages\pip\wheel.py", line 316, in clobber
    ensure_dir(destdir)
  File "c:\program files\python36\lib\site-packages\pip\utils\__init__.py", line 83, in ensure_dir   
    os.makedirs(path)
  File "c:\program files\python36\lib\os.py", line 220, in makedirs
    mkdir(name, mode)
PermissionError: [WinError 5] Access is denied: 'c:\\program files\\python36\\Lib\\site-packages\\charset_normalizer'

If you have any idea, let me know please.

In order to install packages for a Python that was installed as an admin user, you must run Pip as the admin user. Otherwise, you will not have permission to put files into the right folders.