Reputation: 3
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
Reputation: 147
Firstly, you should try again pip install command, Also:
Upvotes: 0
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
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