[英]Python ImportError
I have installed pyqrcode => PyQRCode on Ubuntu 12.04 x86_64. 我在Ubuntu 12.04 x86_64上安装了pyqrcode => PyQRCode 。 by running make && sudo make install.
通过运行make && sudo make install。
At then end of the successful make/make install, the last line is: 在成功的make / make安装结束时,最后一行是:
Installed /usr/local/lib/python2.7/dist-packages/qrcode-0.2.1-py2.7-linux-x86_64.egg
安装/usr/local/lib/python2.7/dist-packages/qrcode-0.2.1-py2.7-linux-x86_64.egg
But when I try to import qrcode I get this error: 但是当我尝试导入qrcode时,我收到此错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "qrcode/__init__.py", line 6, in <module>
from qrcode import _qrcode
ImportError: cannot import name _qrcode
sudo pip install qrcode
worked just fine for me. sudo pip install qrcode
对我来说很好。
My guess is that after compiling, you started Python up from the source directory, and so it looked in the local qrcode
directory -- ie pyqrcode-0.2.1/qrcode
instead of in the usual Python path. 我的猜测是,在编译之后,你从源目录启动了Python,因此它在本地
qrcode
目录中查找 - 即pyqrcode-0.2.1/qrcode
而不是通常的Python路径。 Try running it from another directory. 尝试从另一个目录运行它。 To be specific:
再具体一点:
~/sys/pyqrcode-0.2.1$ python
Python 2.7.3 (default, Apr 20 2012, 22:44:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import qrcode
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "qrcode/__init__.py", line 6, in <module>
from qrcode import _qrcode
ImportError: cannot import name _qrcode
>>>
~/sys/pyqrcode-0.2.1$ cd ~
~$ python
Python 2.7.3 (default, Apr 20 2012, 22:44:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import qrcode
>>> qrcode
<module 'qrcode' from '/usr/local/lib/python2.7/dist-packages/qrcode/__init__.pyc'>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.