简体   繁体   中英

How to solve cannot import name 'ModuleName' error?

I just started to use Python ASE module for research. When I work on the shell this module works perfectly but when I try to use it on idle it gives an error. I don't know how to solve this problem. Any suggestions would be appreciated. I'm using Ubuntu 18.04. Both Python3.6 and 2.7 are installed. I'm using Python3.6 for both shell and idle. For a better understanding I'm writing what I got:

from ase import Atoms



Traceback (most recent call last):
 File "/home/birkan/Desktop/archive/Python/ase.py", line 1, in <module>
   from ase import Atoms
 File "/home/birkan/Desktop/archive/Python/ase.py", line 1, in <module>
   from ase import Atoms
 ImportError: cannot import name 'Atoms'
 [Finished in 0.1s with exit code 1]
 [cmd: ['/usr/bin/python3.6', '/home/birkan/Desktop/archive/Python   /ase.py']]
 [dir: /home/birkan/Desktop/archive/Python]
 [path: /home/birkan/.local/bin:/usr/local/sbin:/usr/local/bin:/usr /sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin]

Please check how you installed ASE module, if your default python version is python2.7 and you simply installed it by using "pip install ase" then your ASE module is installed against version 2.7 which I guess does not support ASE as it is supported from 3.5 upwards. Python3 Version of packages would be a little differently installed, either use pip3 if it is available or try the other options like virtualenv and some other ideas from here:

How to install python3 version of package via pip on Ubuntu?

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