I have this line in my code:
from twilio.rest import Client
But the result is:
Traceback (most recent call last):
File "send_sms.py", line 1, in <module>
from twilio.rest import Client
File "/Users/utilisateur/Downloads/twilio-6.17.0/twilio/rest/__init__.py", line 14, in <module>
from twilio.http.http_client import TwilioHttpClient
File "/Users/utilisateur/Downloads/twilio-6.17.0/twilio/http/http_client.py", line 1, in <module>
from requests import Request, Session, hooks
ImportError: No module named requests
What can I do ?
Whatever your environment is does not appear to have the requests library installed. Run pip install requests either from inside the environment in which this script is running (if you're not already, you should consider using virtualenv or something similar for this to avoid having to install Python packages globally as root).
Note that this likely wouldn't happen if you'd installed the Twilio library via pip, so I'm guessing you simply downloaded it and attempted to run it. If a Python library is in PyPi (which twilio is), you can install it via pip and have its dependencies automatically installed as well.
Related
Running Python3.9 on a Ubuntu Linux Box and properly went through the step installing pdfkit:
pip3 install pdfkit
sudo apt install wkhtmltopdf
Error says :
Traceback (most recent call last):
File "/home/shawn/Development/Websites/MDSova/restapi/app.py", line 8, in <module>
from messaging import Mailbox
File "/home/shawn/Development/Websites/MDSova/restapi/messaging.py", line 8, in <module>
import pdfkit
ModuleNotFoundError: No module named 'pdfkit'
The app was run inside an active environment.
I've read many responses to a similar question; however I have not run across a way to fix it. Does anyone have any suggestions?
I have a virtualbox running centOS. I want to install WTForms and Flask_WTF. I have installed them using pip. However, there are import errors.
[vagrant#oclubs ~]$ pyshell
Traceback (most recent call last):
File "/srv/oclubs/repo/shell.py", line 12, in <module>
from oclubs import *
File "/srv/oclubs/repo/oclubs/__init__.py", line 12, in <module>
from oclubs import objs
File "/srv/oclubs/repo/oclubs/objs/__init__.py", line 15, in <module>
from oclubs.objs.classroom import Classroom
File "/srv/oclubs/repo/oclubs/objs/classroom.py", line 7, in <module>
from wtforms import BooleanField, SelectMultipleField
ImportError: No module named wtforms
Flask imports are fully functional. Any suggestions?
There are sometimes many python interpreters (which searches packages in different folders) and pips (which install packages to a different folders) installed. You can check where your interpreter searches packages by adding a code just before line which caused an error: import sys, os; print(sys.version); print(sys.executable); print(os.environ['PATH']); print(os.environ.get('PYTHONPATH')); print(os.getcwd()). Then run pip show wtforms and see where it was installed. If it's not in the PATH or PYTHONPATH, then pay attention to the pip, which you've used to install a package.
P.S. If you are using virtual env, ensure that you are installing a package with this env's pip, not your system's pip.
Please install again with user vagrant and try again. I assume you've installed in root user or anything.
[vagrant#oclubs ~]$ pip install WTForms
So, I'm trying to upload my python app to heroku but when I use a script with 'requests_toolbelt' it says is not found.
Here my log:
Traceback (most recent call last):
File "girl.py", line 12, in <module>
from Coffe import CoffeAPI
File "/app/CoffeAPI/__init__.py", line 29, in <module>
from requests_toolbelt import MultipartEncoder
ImportError: No module named 'requests_toolbelt'
Here my requeriments.txt:
requests-toolbelt==0.7.1
moviepy==0.2.2.11
requests==2.13.0
Do I need an specific buildpack to run 'requests_toolbelt'?
Try installing requests-toolbelt. Use below command to do that.
# pip install requests-toolbelt
Have you tried to install the package using your command line?
Navigate your command line to the path where you have python installed:
>path\easy_install.exe requests_toolbelt
or
>path\easy_install.exe requests-toolbelt
or
>path\python -m pip install requests_toolbelt
Hopefully this helps you
I had the same issue, and my solution was that
the package was installed by root user
and after changing the access properties of the files, it worked fine.
The command I specifically issued (on ubuntu-like system) was:
sudo chown $USER.$USER -R ~/.local/lib/python3.7/site-packages/
I get the error
Could not import setuptools which is required to install from a source distribution.
Traceback (most recent call last):
File "/home/comp1/anaconda3/lib/python3.5/site-packages/pip/req/req_install.py", line 387, in setup_py
import setuptools # noqa
File "/home/comp1/anaconda3/lib/python3.5/site-packages/setuptools/__init__.py", line 10, in <module>
from setuptools.extern.six.moves import filter, filterfalse, map
ImportError: No module named 'setuptools.extern.six'
even though the same code runs perfectly on a variety of our computers. I do have setuptools installed. I also tried to remove and reinstall it.
EDIT: For some reason, now it works. I don't think we can call it solved, because I did not do anything, but I also don't have the issue anymore.
The python you are using now is anaconda distribution. You have to install setuptools for that ditribution.
So use /home/.../anaconda/lib/python3.5/bin/pip and that will install it for this particular python.
I am running python 2.7 on ubuntu 12.04. I did pip install tornado in a virtual environment and python reports that it was a successful installation. But when I run the code in the file tserver.py I get the following error:
(venv)$ python tserver.py
Traceback (most recent call last):
File "tserver.py", line 1, in <module>
from tornado.wsgi import WSGIContainer
ImportError: No module named tornado.wsgi
I found this question describing a very similar problem Python Tornado: WSGI module missing? -- but my file is not called tornado.py so the answer does not help me.
Had you named the server file initially as tornado.py ? because, I had and even after changing i still got that error.
I fixed it after I did a sudo pip install tornado --upgrade
After this i closed the terminal and restarted it. Then, in the python interpreter i tried import tornado and the error was gone.
Also also remove any tornado.pyc or tornado.py file in the directory where your application is present