找不到Python模块

ram*_*am1 3 python

如何从Python解释器导入pyBarcode?根据pyBarcode文档,第一步是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
Run Code Online (Sandbox Code Playgroud)

phi*_*hag 5

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

pip install pyBarcode
Run Code Online (Sandbox Code Playgroud)


Tor*_*ler 5

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

或者,您可以使用

import sys
sys.path.append(r"C:\path to pyBarcode")
import barcode
Run Code Online (Sandbox Code Playgroud)