Python 如何安装“glob”模块?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42964691/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install the 'glob' module?
提问by Omar Amr
I am running ubuntu 14.04 and trying to launch ROS Simulator. I have this error:
我正在运行 ubuntu 14.04 并尝试启动 ROS Simulator。我有这个错误:
ImportError: No module named 'glob'
Installing glob2 does not solve the problem.
安装 glob2 并不能解决问题。
python -m site
output:
python -m site
输出:
sys.path = [
'/home/omar',
'/opt/ros/indigo/lib/python2.7/dist-packages',
'/home/omar/anaconda3/lib/python35.zip',
'/home/omar/anaconda3/lib/python3.5',
'/home/omar/anaconda3/lib/python3.5/plat-linux',
'/home/omar/anaconda3/lib/python3.5/lib-dynload',
'/home/omar/anaconda3/lib/python3.5/site-packages',
'/home/omar/anaconda3/lib/python3.5/site-packages/Sphinx-1.4.6-py3.5.egg',
'/home/omar/anaconda3/lib/python3.5/site-packages/numba-0.29.0-py3.5-linux-x86_64.egg',
'/home/omar/anaconda3/lib/python3.5/site-packages/glob2-0.4.1-py3.5.egg',
'/home/omar/anaconda3/lib/python3.5/site-packages/setuptools-27.2.0-py3.5.egg',
]
USER_BASE: '/home/omar/.local' (exists)
USER_SITE: '/home/omar/.local/lib/python3.5/site-packages' (doesn't exist)
ENABLE_USER_SITE: True
回答by Ishan Khatri
You are using Python 3.X and you are installing glob2 here are the correct glob versions
您正在使用 Python 3.X 并且您正在安装 glob2,这里是正确的 glob 版本
for python 2.7
对于蟒蛇 2.7
sudo pip install glob2
for python 3.7
用于蟒蛇 3.7
sudo pip3 install glob3
hope it helps.
希望能帮助到你。
回答by cjds
ROS does not support Python 3 in the first place, so I would not recommend you use it. You should install 2.7.
ROS 首先不支持 Python 3,因此我不建议您使用它。您应该安装 2.7。
Redownload it: https://www.python.org/downloads/
重新下载:https: //www.python.org/downloads/
Here's the source for glob: https://docs.python.org/2/library/glob.html
这是 glob 的来源:https: //docs.python.org/2/library/glob.html
As you can see it's in the Lib package which marks it as standard
如您所见,它位于 Lib 包中,将其标记为标准