I'm working with the google-api-python-client library with the following setup:
Python3.4.3 in a virtual environment (using pip8.1.1)
I'm getting error from the following code: AttributeError: 'module' object has no attribute 'file'
store = oauth2client.file.Storage(credential_path)
The code is from the Google Python Quickstart example and runs fine under Python 2.7.10
Thanks in advance!
I was able to get it to work by rewriting the import statement:
from oauth2client.file import Storage
Not sure why this works, but it does.
Related
I am new to Cloud SDK, and I tried to invoke the following action, but I get error : " stderr: ModuleNotFoundError: No module named 'cloudant'",.
NOTE:
Console ==> IBM cloudant python 3.9 SDK: No module named 'cloudant'"
CLI ==> Python 3.86 : accepted the module without error
Question :==> I need to know how to do it using the CLI.
If you have a solution please let me know in time. Thank You!!.
from cloudant.client import Cloudant
import requests
import json
dict = {"COUCH_USERNAME": "--bluemix",
"IAM_API_KEY": "---bluemix"}
def main(dict):
client = Cloudant.iam(user_name=dict["COUCH_USERNAME"],
api_key=dict["IAM_API_KEY"],
connect=True)
my_database=client['reviews']
return my_database.json```
Yes I did. I have used Python 3.7 and it works. However, it is depreciated on IBM cloud
The Python cloudant module is EOL and is replaced by the ibmcloudant module.
As per the Functions documentation the 3.9 runtime contains the new ibmcloudant module.
You should migrate your action code to use ibmcloudant instead of cloudant. If you can't want to migrate your code then you could force it to use the 3.7 runtime with --kind python:3.7 or create a custom 3.9 runtime with the cloudant module installed.
I am trying to attach instance profile to an EC2 instance using boto3. I am following boto3 documentation https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.associate_iam_instance_profile
But It fails with below error:
AttributeError: 'EC2' object has no attribute 'associate_iam_instance_profile'
Could you please help me with this ?
This is the code snippet
import boto3
ec2=boto3.client('ec2',region_name='ca-central-1')
response = ec2.associate_iam_instance_profile(IamInstanceProfile={'Arn': 'arn:aws:iam::1234567890:instance-profile/instanceprofilename','Name': 'instanceprofilename'},InstanceId='i-1234567890')
A help will be much appreciated.
boto3==1.4.3
Python 3.8.6
Thanks
You are referring to documentation of boto3 version 1.17.112 and you are using a bit outdated boto version. So if there is no version constraint first thing you can do is to update your boto3 version.
pip install boto3==1.17.112
For running google contacts API, these libraries are used:
import atom.data
import gdata.data
import gdata.contacts.client
import gdata.contacts.data
The problem is these libraries are not installed correctly.
I am getting these type of errors.
1) AttributeError: module 'atom' has no attribute 'LinkFinder'
2) ImportError: No module named core
Any solution for doing this importing the libraries correctly?
How to install these library correctly to execute my code?
EDIT
I want to know how to remove these errors after installing atom and gdata.
I am now using Python to download files from Dropbox, and I following this tutorial. However, it did not succeed on the first two lines of codes:
import dropbox
dbx = dropbox.Dropbox('YOUR_ACCESS_TOKEN')
My Python complains that AttributeError: 'module' object has no attribute 'Dropbox' Any ideas?
After careful examination, I found the reason is because I am using functions from dropbox-v2 while in my machine dropbox-v1 was installed.
I am currently attempting to use the cex.io Python API for accessing financial data. Here is a link to github with the library: https://github.com/matveyco/cex.io-api-python
I installed it on MacOS X by using "python setup.py install" in Terminal. In the link above, it says to initialize the class we should use the following:
import cexapi
api = cexapi.api(username, api_key, api_secret)
However, when I put this code in a .py file in a directory without any other files, bash responds with:
AttributeError: 'module' object has no attribute 'api'
I am pretty sure the library is correctly installed (Python has no problem importing cexapi). It is clear to me that there is something about Python objects that I don't understand or I must have incorrectly installed the module.
Just in case it helps, I ran the following in the Python interpreter:
import cexapi
cexapi.__file__
And got the following:
'/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/cexapi-0.1-py3.4.egg/cexapi/__init__.py'
This command should show where the module is stored. Any help would be greatly appreciated, as I need to use this API. Thanks.
use upper case letters:
import cexapi
api = cexapi.API(username, api_key, api_secret)