找不到Python模块

2024-05-10 06:40:01 发布

您现在位置:Python中文网/ 问答频道 /正文

如何从Python解释器导入pyBarcode?根据pyBarcode documentation,第一步是import barcode。当我尝试它说没有这样的模块。

~# python
Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48)
[GCC 4.4.5] on linux2

>>> import barcode
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named barcode

Tags: 模块importmostondocumentation解释器barcodedec
2条回答

确保包含模块的目录位于PYTHONPATH环境变量中。

或者,您可以使用

import sys
sys.path.append(r"C:\path to pyBarcode")
import barcode

在使用(importing)pyBarcode之前,您必须install它,例如

pip install pyBarcode

相关问题 更多 >