3

I've been following this tutorial here: on introduction to the youtube API. ive been through the google api client gethub page as well as google's own api liturature page for pip install and virtualenv tutorials to use the correct versions and seperate enviroments and still get the error:

"ModuleNotFoundError: No module named 'googleapiclient'"

I have seen this responded to and fixed on multiple other posts including solutions to upgrade the google client for which the command window returns that requirements are already satisfied for all files in the module so i am assuming that means the client is successfully installed inside my virtual enviroment.

Since I am new to alot of this and virtual enviroments, i did also try creating a new script to run the same code outlined below in case my file created before the creation of the virtualenv was somehow running outside the path of the the virtualenv i created but returned the same issue.

Any help at all or additional troubleshooting to solve this issue. all i am trying to do so far is install build from the googleapiclient.discovery module.

my code:

from googleapiclient.discovery import build

Everything i've done so far in the console

console:

pip3 install virtualenv

"warning virtualenv installed not on PATH"

pip uninstall virtualenv
sudo pip install virtualenv
virtualenv new_env
source new_env/bin/pip install google-api-python-client

Everything ive done since running the script and seeing the error message:

console:

pip install google-api-python-client
"requirements already satisfied"
pip install --upgrade google-api-client
"requirements already satisfied"
pip install --upgrade google-api-python-client --ignore-installed six
"installing collected packages"
4
  • please edit your question and include minimal reproducible example Commented Jul 28, 2022 at 17:27
  • Please provide enough code so others can better understand or reproduce the problem.
    – Community Bot
    Commented Jul 28, 2022 at 17:27
  • You should follow the tutorial here Commented Jul 28, 2022 at 17:29
  • that tutorial has been followed as seen in the console commands list, the OAuth portion is to grab private information and is not needed to make public requests. I also dont think that missing it would reveal the same error message.
    – Tswam17
    Commented Jul 28, 2022 at 17:42

2 Answers 2

3

Python provides various ways to install tools and packages.

Here's my standard setup:

python3 -m venv venv
source venv/bin/activate
python3 -m pip install google-api-python-client

Then you can write Python files or use the REPL by running e.g. python3:

Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Then you can import the API Client Library and you should be good:

>>> from googleapiclient.discovery import build
>>> API_KEY = "[YOUR-API-KEY]"
>>> build("youtube", "v3", developerKey=API_KEY)
<googleapiclient.discovery.Resource object at 0x7bafdbcfd040>

When you're done consider deactivate'ing and removing the venv folder.

0
pip install google-api-python-client

This worked for me.

Not the answer you're looking for? Browse other questions tagged or ask your own question.