Can't use spotipy even though I installed it - python

I installed spotipy on my laptop using pip install spotify
at cmd. I checked that spotipy was successfully installed using pip install check.
pip install spotify error message
result of pip list
However, when I try to use spotify on kaggle, I get an error message that says there is no module named spotify.
I had similar issues with jupyter notebook. What should I do to fix this?

When you install a package using pip, you get to use it through Python. Spotipy isn't a CLI tool, and cannot be accessed by simply typing it on cmd. If you were to open up a Python terminal and try import spotipy, it would import properly.
Consider the block of code on the official Spotipy doc. It imports Spotipy, then uses it within the code itself:
import spotipy
...
spotify = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())
results = spotify.artist_albums(birdy_uri, album_type='album')
Also consider reading up on Python packages and how they work.

Related

Python Firebase (Real-time database) on Replit

I want to connect to firebase on replit using python. I'm using the code below:
from firebase import firebase
firebase = firebase.FirebaseApplication("my firebase url", None)
data = {
'ddfjaklfbja': 'dklabja;kdlf',
'adfjlkgadjf': 'dkaljbaowq',
'afbiouadofpia': 'dsajklbjanzm'
}
result = firebase.post('/test1', data)
print(result)
However, when I try to run it, it returns an error saying that there is no module named urllib3:
ModuleNotFoundError: No module named 'urllib3'
When I try to use the packages tab to install it on the left, it does not install and returns with the same error (there are multiple lines but the last line says this). How can I fix it?
Their are multiple things you can try:
Open your command prompt and enter "pip install urllib3"
If it can't install it try this: python3 -m pip install urllib3 or pip3 install urllib3
Perhaps it helps when you add this to your python file: import urllib3
this issue is related to Python path, and with the python interpreter. Make sure you are using the python interpreter in which you have installed the modules. (If using 3.9 use python 3.9 as interpreter as opposed to 3.10). If this doesnt work check python path. Other easy solution is to change your project folder to one that imported your modules correctly.

ModuleNotFoundError with pyDataverse - API for Harvard Dataverse

I'm trying to use a Python API to access and download data the Harvard Dataverse. The FAQs page for using APIs to access the Dataverse suggests the dataverse package, and the .readme for that GitHub repo points towards an alternative pyDataverse package. When I try to run and import these modules in a Jupyter Notebook I get a ModuleNotFoundError - but I have all the dependencies for these modules installed (requests, jsonschema, urllib3), so I'm not sure what the problem is.
!pip install pyDataverse
import pyDataverse
Returns:
ModuleNotFoundError: No module named 'pyDataverse'
And the same issue when I try the dataverse module - this module isn't available through PyPI so I ran pip install -e git+https://github.com/IQSS/dataverse-client-python.git#egg=dataverse instead (see the readme) and then ran import dataverse - which produced the same error. Any idea what I'm doing wrong? Or alternative suggestions for APIs to access Dataverse repositories?

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?
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.
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/
Firstly, you should try again pip install command,
Also:
If you are using an different place such as Pycharm or Jupyter or Anaconda, you must reinstall that module in that working environments
If you are using python's own ide, try add your current python path to system path
Re-read usage of your module

Python Linux Google drive API client install modules not found

I'm trying to start working with google drive API from python on my local Linux machine. I want to be able to move files back and forth to Google drive from my local machine. I just started learning Python yesterday and I'm having problems with the Google quickstart instructions. when I try to run the quickstart code at https://developers.google.com/drive/v3/web/quickstart/python with python3 I get this error:
ImportError: No module named 'apiclient.discovery'
which results from these import statements at the top of the file.
from __future__ import print_function
from apiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools
As per the instructions I installed what I thought i needed with the command
pip install --upgrade google-api-python-client
But I'm getting this error. I notice if i comment out the line
from apiclient.discovery import build
then the rest of the import statements are ok, and the script starts executing and browser pops up asking for authentication, but then obviously when it reachs the 'build' function call in the script it breaks. What am I doing wrong?
I've tried installing the lib folder containing the modules to the local directory where my script is executing, but I think that's only important if you're using google app engine which I am .... not? I don't think I am right? When i did that i tried changing the import statement to
from lib.googleapiclient.discovery import build
I get the same error, but I've actually opened up that file in lib/googleapiclient/discovery.py in my local directory and in the code is
...
def build(serviceName,
version,
http=None,
discoveryServiceUrl=DISCOVERY_URI,
developerKey=None,
model=None,
requestBuilder=HttpRequest,
credentials=None,
cache_discovery=True,
cache=None):
...
So why in the world wouldn't this import statement work? I've also tried changing the statements from
from apiclient.discovery import build
to
from googleapiclient.discovery import build
and I get the same error, No module named 'googleapiclient'
I've installed 3rd party modules yesterday with pip and I never had any problems. What's going on? Thanks for your help.
Check your python and pip version, and try pip freeze to check the installed package.
python --version
pip --version
pip freeze
Please check your python version, where your pip is from (/usr/lib/python2.7 or /usr/lib/python3.6 or the other virtualenv) and whethergoogle-api-python-client is in the output of pip freeze.
Try to reinstall google-api-python-client.
sudo pip install --force-reinstall google-api-python-client
apiclient is the old name, so it is better to use googleapiclient for import.
from googleapiclient.discovery import module

I can't get coinmarketcap library working

First I installed the coinmarketcap from the pycharm project interpreter.
Then I run the code below:
>>> from coinmarketcap import Market
>>> coinmarketcap = Market()
>>> coinmarketcap.ticker(<currency>, limit=3, convert='EUR')
But I got this:
ImportError: cannot import name Market
Then I thought it is not the right library, so I installed the following API from https://github.com/mrsmn/coinmarketcap-api thinking that pycharm might have installed some other library.
So I downloaded the library from Github and I used the python setup.py install command and installed the library from Github without any problems.
I tried to rerun the code, but the problem still persists:
ImportError: cannot import name Market
I have finally solved it. Actually I needed to uninstall it within pycharm. Then I installed it using the pip install coinmarketcap and after that it works.
Thank you for your help!
I have installed it using pip and tried to import it and did not get any error.so, can you check whether the installation is done with out any error

Categories