0

I created a virtual environment on my Desktop called project_env. I then installed the Google API Python Client from github (https://github.com/googleapis/google-api-python-client). Then created a Python file called youtube.py with the following code. When I run the file I get "ImportError no module googleapiclient"

  from googleapiclient.discovery import build

  api_key = "My Key"

  youtube = build('youtube', 'v3', developerKeys=api_key)

  request = youtube.channels().list(
   part='statistics',
  forUsername='livelifetothefull'
  )

 response = request.execute()
  print(response)

I'm very new to this, so any help would be much appreciated.

AzyCrw4282
  • 7,222
  • 5
  • 19
  • 35
newtocode
  • 21
  • 1
  • 4

2 Answers2

0

It would have been great if you had provided details on how you are running it and what version of Python you are using. Without that, I have provided solutions that applies in a general context.

  1. You may need to add your venv to your path so that it can recognize the site-packages. See here on how you can do that.

  2. It may also mean that the interpreter may not be resolving to the correct venv. For example, if you running through cmd line try running it with python3 if you doing with python or vice-versa.

  3. Change of library issue, see here on that.

AzyCrw4282
  • 7,222
  • 5
  • 19
  • 35
0

You can try these commands :

cd project_env
source bin/activate
bin/pip install wheel
bin/pip install google-api-python-client
bin/python -c "from googleapiclient.discovery import build"
Philippe
  • 20,025
  • 2
  • 23
  • 32