exceptions.ImportError: cannot import name TwitterAPI - python

Keep getting this error and not sure why,
exceptions.ImportError: cannot import name TwitterAPI
TwitterAPI library is already downloaded, I download it first from pip install twitterapi, didnt work, uninstall it and download the .zip file for it, and tried to install it using
python setup.py build
python setup.py install
didnt work too, still getting the same error, any ideas?
the code:
from TwitterAPI import TwitterAPI
TRACK_TERM = 'NBA'
api = TwitterAPI(consumer_key='__', consumer_secret='__', access_token_key='__', access_token_secret='__')
r = api.request('statuses/filter', {'track': TRACK_TERM})
for item in r:
print (item['text'] if 'text' in item else item)

Please write this command that set:
pip install python-twitter

Because you installed TwitterAPI from a zip file, the package is not necessarily in a path where Python will see it. That is why import fails. Your best bet is to try installing with pip again, but this time use the proper case since pip is case sensitive:
pip install TwitterAPI

You should to install requests (or upgrade them) like in this issue.
pip install requests
or
pip install --upgrade requests

Probably need to set PYTHONPATH:
export PYTHONPATH=`pwd`

Related

Module Not found error: office365 not found

I have seen this issue with some resolutions already, but none have worked for my issue. I have pip installed the latest version of office365(v 2.2.0) to my knowledge using the command:
pip install office365-rest-client
I am trying to import using the following lines of code:
from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.files.file import File
I receive the following error:
ModuleNotFoundError: No module named 'office365'
Just to test it out, I uninstalled and reinstalled pandas, then successfully imported pandas into my project.
Install this
pip install Office365-REST-Python-Client
pip install office365
After that, restart your IDE and errase and write again the imports. I no have idea why this worked for me
ATTENTION - You must make the letter O lowercase in both install commands, as below. Capital O does not work.
pip install office365-REST-Python-Client
pip install office365
You also need to install the office365 library as well as office365-rest-client
pip install office365

Python 3.6 import requests

Hi im pretty new to python and im following some tutorials online.
im using the latest version of python 3.6 when i try and import requests or bs4 is says
ModuleNotFoundError, No module named 'requests'
although it is installed i can see it in site packages i used pip to install whatever i seem to do it doesnt seem to be able to find it
here is the code
import requests
from bs4 import BeautifulSoup
import operator
def start(url):
word_list = []
source_code = requests.get(url).text
soup = BeautifulSoup(source_code)
for post_text in soup.findAll('div'):
content = post_text.string
words = content.lower().split()
for each_word in words:
print(each_word)
word_list.append(each_word)
start('http://localhost/budget_app/dashboard.php')
this is the error
ModuleNotFoundError, No module named 'requests'
Run following command on your virtual environment:
sudo pip install requests
Run following command if you have more than one python3.x
python3.6 -m pip install requests
If your facing issue with proxy setting then run below command:
pip install requests --proxy http://<username>:password<password>#<IP>:<port>
--proxy [user:passwd#]proxy.server:port.
I was having the same issue. Despite having the requests packages appeared as installed when I would run the pip install requests and the pip3 install requests. The package would also show as present when running the pip freeze command.
I used the file explorer window to find the location of the library and manually copy and paste the package files from the site-package folder and into it parent Lib directory.
I hope this helps.

Importing Python package

I'm the owner of this repo and I'm trying to import it from another project. I installed it using pip via pip install git+https://github.com/FranGoitia/shapelets, but I'm not able to import it. I tried importing shapelets and shapelets_classifier and neither worked.
you don't install the git repo the right way.
try this:
pip install -e git+git://github.com/FranGoitia/shapelets#master#egg=shapelets_classifier-1.0-py3.5
then you can use
import shapelet
As you can see in the repository, the file you're actually trying to import from is shapelet.py, so try import shapelet

Import error installing tlslite

I'm trying to install tlslite. After installed the module I've tried to test it and I receive this error:
from .checker import Checker
ImportError: No module named checker
I've checked on my pip module list and checker is installed...
Any idea?
Thanks!
Assuming you installed tlslite correctly, try this:
>>> from tlslite.checker import Checker
If that doesn't work, check that tlslite is in your site packages
To work with tlslite I recommend to use a virtualenv and install TlsLite inside:
cd ~/virtualenv/ # <- all my virtualenv are here
virtualenv myvenv
source ~/virtualenv/myvenv/bin/activate
pip install -q -U pip setuptools # ensure last version
pip install tlslite
With that in hand, you can use the Checker:
$ python
>>> from tlslite.checker import Checker
>>>
Et voilà !

Where is BeautifulSoup4 hiding?

I did sudo pip install BeautifulSoup4 and got an awfully optimistic response:
Downloading/unpacking beautifulsoup4
Running setup.py egg_info for package beautifulsoup4
Installing collected packages: beautifulsoup4
Running setup.py install for beautifulsoup4
Successfully installed beautifulsoup4
Cleaning up..
but when I try to use import BeautifulSoup4 or from BeautifulSoup4 import BeautifulSoup4 in a script, python says there's no module by that name.
> import BeautifulSoup
ImportError: No module named BeautifulSoup
Update: pip tells me beautifulsoup4 in /usr/local/lib/python2.6/dist-packages but I'm running 2.7.2+ (and print sys.path sees 2.7 paths) ... so now I need to figure out why pip is putting things in the wrong place.
Try import bs4. It's unfortunate there's no correspondence between PyPI package name and import name. After that the class names are the same as before eg. soup = bs4.BeautifulSoup(doc) will work.
If that still doesn't work, try pip install again and note the path to the package install. Then in your python console run import sys and print sys.path to make sure that the path is there.
You might need to explicitly specify pip-2.7 or switch to easy_install (or easy_install-2.7)
Try this:
from bs4 import BeautifulSoup
I had this issue while using VS Code and the Pylance extension. I was able to resolve it by finding the location of my python packages (in my case it was "c:\python39\lib\site-packages"), and adding that to the external resolution paths in Pylance's settings. Pylance was then able to locate the import. I used below code segment to import BeautifulSoup from bs4.
from bs4 import BeautifulSoup
After trying the easy_install and pip if things dont work then download the tz package from the package website untar it in a folder. Now open cmd window and go to the directory where you unzip the tz and run the command 'python setup.py install' IT should work

Categories