简体   繁体   中英

Import error with atom module

from __future__ import division
import sys, time, os.path, magic
import atom.data, gdata.client, gdata.docs.client, gdata.docs.data

The complete code is at http://planzero.org/blog/2012/04/13/uploading_any_file_to_google_docs_with_python

I am working in Ubuntu 14.04 on virtualbox. I am using Python 2.7.6. I have both the atom and the gdata modules installed successfully with latest versions. But my code gives me the following error while importing the modules.

Traceback (most recent call last):
  File "test14.py", line 16, in <module>
    import atom.data, gdata.client, gdata.docs.client, gdata.docs.data
  File "/usr/local/lib/python2.7/dist-packages/atom/data.py", line 24, in <module>
    import atom.core
ImportError: No module named core

I also tried to import the entire atom module instead.

import atom, gdata.client, gdata.docs.client, gdata.docs.data

Gives the following error:

Traceback (most recent call last):
  File "test14.py", line 16, in <module>
    import atom, gdata.client, gdata.docs.client, gdata.docs.data
  File "/usr/local/lib/python2.7/dist-packages/gdata/client.py", line 35, in <module>
    import atom.client
  File "/usr/local/lib/python2.7/dist-packages/atom/client.py", line 27, in <module>
    import atom.http_core
ImportError: No module named http_core

Both core.py and http_core.py are present at /usr/local/lib/python2.7/dist-packages/atom/. I tried directly importing these modules

import atom.http_core, atom.core

It worked. So what is going wrong?

I had the same troubles when I was trying to install (Mac OSX 10.10.5, python version 2.7.6). I did the following

  1. Uninstall atom (pip uninstall atom) and let gdata install it in its setup.py file

  2. pip install tlslite

  3. Run the gdata-python-client-master/tests/run_data_tests.py file

I found the solution here

Sounds like either the module has errors or you're missing some files. Based on this I would suspect the latter.

If you know where the atom module files are(probably in some directory from PYTHON_PATH ), check if there is an atom\\core.py file. If not, check the installing instructions(you may have needed to run some script first) or reinstall the module.

If that fails, you can try to comment out the atom.core import but it's very likely it is used somewhere in atom.data and you will only get more errors.

Here is something that worked for me. Not a solution I would go for if I had a choice, but it did work!

First I copied atom and gdata directories from /usr/local/lib/python2.7/dist-packages to my working directory. I did this because it made editing any files easier. Python looked for the import modules first in the working directory. And I got permissions on the copied directories and files. Plus I retain the original copy in the original location.

Next I edited the data.py file from atom. I changed the import statement from import atom.core to import core .

Next I edited the client.py file from atom. I changed the import statement from import atom.http_core to import http_core .

This seemed to be working as I didn't get any errors at these points anymore. Now I realized that in both of the above instances, import statement tried to import the module as atom.module from inside the atom package. So then I proceeded to change all the instances where atom.module was used in the above files to just module . The code ran fine.

If you have installed atom using pip and have tried uninstalling it using pip uninstall and it does not work. Then delete it manually using sudo rm -rf <path_to_atom> and then reinstall gdata-python-client using sudo python setup.py install

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM