Stella Meku
Stella Meku

Reputation: 3

Tweet a message using python

i am a newbie in Python and want to try to tweet using python using this code, but after i run it, in python shell said that

from twython import Twython
ModuleNotFoundError: No module named 'twython'

Can someone help what's wrong with my code?

Upvotes: 0

Views: 150

Answers (3)

Barış Akın
Barış Akın

Reputation: 147

Firstly, you should try again pip install command, Also:

  1. If you are using an different place such as Pycharm or Jupyter or Anaconda, you must reinstall that module in that working environments
    1. If you are using python's own ide, try add your current python path to system path
    2. Re-read usage of your module

Upvotes: 0

Paco Wong
Paco Wong

Reputation: 720

Welcome to Python family! When a module is first imported, Python searches for the module and if found, it creates a module object, initializing it. If the named module cannot be found, a ModuleNotFoundError is raised.

As a beginner, you should learn how to install a package in Python by going through the tutorial: https://packaging.python.org/tutorials/

Next, you should follow the installation guide in https://twython.readthedocs.io/en/latest/usage/install.html

In the command prompt, you should run

pip install twython

Observe if any error pops up during the installation.

To see if Twython works correctly, start Python in the command prompt,

python

In the Python environment, run the following command:

>>> from twython import Twython

If Twython is installed correctly, you should not see the ModuleNotFoundError.

Upvotes: 1

Bharat_K
Bharat_K

Reputation: 336

ModuleNotFoundError means that the module is not installed. Sometimes may be the module is installed but it is installed in a place where python does not look for it. In your case I feel you have not installed twython.

Open command prompt and type the following command pip install twython

This should install the twython and after this if you run your file the error will not appear.

Check this out for more information on twython https://pypi.org/project/twython/

Upvotes: 0

Related Questions