【发布时间】:2023-04-03 15:48:01
【问题描述】:
我正在尝试在我的 ubuntu 上安装一个 python 包。我正在尝试通过我编写的安装脚本安装它。setup.py 脚本如下所示:
from setuptools import setup
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
setup(
name = 'pyduino',
description = 'PyDuino project aims to make python interactive with hardware particularly arduino.',
url = '###',
keywords = 'python arduino',
author = '###',
author_email = '###',
version = '0.0.0',
license = 'GNU',
packages = ['pyduino'],
install_requires = ['pyserial'],
classifiers = [
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Topic :: Software Development :: Build Tools',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
],
scripts=['pyduino/pyduino.py'],
)
包安装在 /usr/local/bin 目录中。但是当我在 /usr/local/bin 之外导入模块时,会发生导入错误。我尝试将路径更改为 /usr/local/bin 并且它运行良好并且不会出现导入错误。如何安装包以便可以在任何目录中导入模块?提前谢谢...
【问题讨论】:
-
你确定包安装在
/usr/local/bin
吗?你是用什么命令安装的? -
@LaurIvan 是的,我确定。当我将路径设置为
/usr/local/bin
时,不会发生导入错误,我可以导入模块 -
@LaurIvan 我正在使用
sudo python setup.py install
安装软件包
本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:如何将 python 包安装到 /usr/local/bin? - Python技术站