I am using an online spreadsheet app called AirTable and need to be able to access the API using Python.
There is a python interface to the API as outlined on Github:
https://github.com/bayesimpact/airtable-python
I've followed the getting started directions and when I run the code I get the following error:
AttributeError: module 'airtable' has no attribute 'Airtable'
What am I doing wrong?
Temporary fix:
from airtable import airtable
Permanent fix:
1 find your airtable installed path
2 find the ini file
3 Remove the #
4 Specify the class you need to use once imported
from airtable import airtable
class Airtable(object):
pass
May be more class you need to add.
I had this problem as well. The filename which I was writing in was named airtable.py
When I changed the filename to air.py it was able to import airtable without an issue.
First, check that if your project has a file name "airtable.py"
"You should never use the same name for a python file that is for a python library, python confuses its self, deciding where should it import, its priority is to import from the project files first and go to libraries later"
if that does not works then you may have installed the wrong library
pip uninstall airtable
python working library for airtbale is
pip install airtable-python-wrapper
Related
I am following the tutorial here:
http://www.prokopyshen.com/create-custom-zipline-data-bundle
and trying to set up a custom bundle to get price from custom, non US financial assets. I am stuck on the line that says:
Advise zipline of our bundle by registering it via .zipline/extension.py
My extension.py file is located in the .zipline/ directiory and has the following code:
from zipline.data.bundles import register
from zipline.data.bundles.viacsv import viacsv
eqSym = {
"CBA"
}
register(
'CBA.csv', # name this whatever you like
viacsv(eqSym),
)
I don't get what it means to register the bundle via .zipline/extension.py though? I thought it might mean to just run the extension.py file from my terminal via a:
python extenion.py
but that fails and says:
ImportError: No module named viacsv
How do i register this bundle?
I also followed this tutorial and I must confess this part is a little confusing.
First of all, I don't think it's necessary to run:
$ python extension.py
The error message you get probably comes from the fact that Python cannot find the viacsv.py file in sys.path (the places where it looks for modules, etc.). In the tutorial you mentioned, it's not really clear what to do with this file. As far as I am concerned, I just saved the viacsv.py file in my local site-packages directory. As I am on Linux I put it there ~/.local/lib/python2.7/site-packages but it might different for you. You can run the following python script to find out:
import sys
for dr in sys.path:
print dr
Then I just substituted from zipline.data.bundles.viacsv import viacsv with from viacsv import viacsv in extension.py.
I suspect you might be looking for the wrong place for the extension.py file.
For windows machine, the file is under "~\.zipline\extension.py". In my case, it's under "C:\Users\XXXX\.zipline\extension.py".
I had been looking at zipline folder under conda's site-packages folder, and couldn't find it. Then created an extension.py myself wondering why it's not called.
Check a related post here https://www.quantopian.com/posts/zipline-issue-while-creating-custom-bundle-to-bring-yahoo-data.
Same issue here, #Gillu13 pointed me to this solution.
I installed zipline through conda. So zipline is installed in
home/me/anaconda3/envs/krakenex/lib/python3.6/site-packages
in there you will find zipline/data/bundles and you can put viacsv.py in there...
then
from zipline.data.bundles.viacsv import viacsv
works
The same question has been asked a number of times but I couldn't find the solution.
After I install a package using pip, I am able to import it in python console or python file and it works as expected.
The same package when I try to include in django, it gives import error.
Do I need to modify settings.py file or any requirement that I need to add? I am driving django with the help of virtual env.
Eg:
I am using BeautifulSoup and I am trying to import from bs4 import BeautifulSoup and I am getting error ImportError: No module named 'bs4'
This error only comes in django. I am not able to figure out why this is happening.
Screenshot attached for reference.
1. python console - shows no error
2. django console- import error
I am sorry as it is difficult to read the console but any other thing that I can include which will help me make myself more clear will be appreciated.
You don't show either the code of your site or the command you ran (and the URL you entered, if any) to trigger this issue. There's almost certainly some difference between the Python environment on the command line and that operating in Django.
Are you using virtual environments? If so, dependencies should be separately added to each environment. Were you operating from a different working directory? Python usually has the current directory somewhere in sys.path, so if you changed directories it's possible you made bs4 unavailable that way.
At the interactive Python prompt, try
import bs4
bs4.__file__
That will tell you where bs4 is being imported from, and might therefore give you a clue as to why it's not available to Django.
Hello I'm trying import a module import Image. I recieved this error <type 'exceptions.ImportError'> Cannot import module 'Image'
I looked for a solution and found this Install Python Module in local install of web2py
So "how can I drop modules in app/modules folder" so web2py will check there first when import something or if anyone knows a better solution then the provided solution please help.
If you are using the Windows or Mac web2py binary, they include their own Python interpreter, so they will not use your system's installed version of Python nor see any of its modules. If you have your own version of Python installed, you're better off running web2py from source, which is just as easy (just download and unzip -- run with the web2py.py file rather than web2py.exe or web2py.app).
Im trying to import a company module into my software and I get the error:
ImportError: No module named config
from:
from pylons.config import config
So obviously, the module that im importing requires pylons.config but cant find it in my virtual environment.
If I go to the terminal and try some Python scripts I can seem to find the config file if I try:
from pylons import config
but will error if I try:
import pylons.config
Why is this?
And does anybody how or where I can get:
from pylons.config import config
to work. Bearing in mind that I cannot change the code for this module, only mine which is importing it or my own system files.
UPDATE
If anyone finding this page has a similar problem you may find that you are trying to run two modules with different versions of Pylons.
For example, you are creating a login application called myApp. You have some Python modules which help with login handling called pyLogin.
First you install pyLogin with python setup.py install. This adds the libraries to your site packages and updates any libraries it depends on, such as SqlAlchemy.
Next you install myApp in the same way which again updates libraries and dependencies.
This problem will occur if pyLogin and myApp are using different versions of Pylons. If pyLogin is using Pylons 0.9.6 and myApp is using Pylons 1.0 for example, then the pyLogin code will be called from myApp but it will be running in the wrong Pylons framework and hence will require EITHER from pylons import config or from pylons.config import config, but will only work with one. If it is using the wrong call for Pylons then you will find yourself with this error message.
So the only solution to this error is to either find earlier or later libraries which use the same Pylons version as your application or to convert your application to the same Pylons version as the libraries you are using.
There is a diffrence between two usages...
import loads a Python module into its own namespace, while from loads a Python module into the current namespace.
So, using from pylons import config imports config to to your current namespace. But trying to import a class or function using import is not possible since there is no namespace to keep them... You can only import modules, and use functions or classes via calling them with their own namespace like
import pylons
....
pylons.config #to retreive config
More about import in Python
I'm trying to use gdata python but unfortunately when I execute my script it keeps on saying me "ImportError: No module named docs".
I have tried importing it by running python directly in shell and everything seems fine.
Can someone help me out with this problem?
edit:
import gdata.docs
import gdata.docs.service
import gdata.docs.client
import gdata.spreadsheet.service
I had this problem when I started. My guess is that your Gdata library is not on your Python path. For example, my gdata and atom modules are located in the Python27/Lib/site-packages folder.
Another option is to update your PATH environmental variable to point to the current location of the Gdata files.