Linux 上的 Python 路径 [英] PYTHONPATH on Linux
本文介绍了Linux 上的 Python 路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是这方面的新手,我已经开始学习 Python,但我有一些我无法理解的问题,
I'm novice in this, and I have started learning Python, but I have some questions that I'm not be able to understand,
- PYTHONPATH(在 Ubuntu 上)究竟是什么?是文件夹吗?
- Ubuntu 是否默认提供 Python,还是必须明确安装?
- 所有模块所在的文件夹在哪里(我有很多名为
python_
的文件夹)? - 如果我希望在编程时使用一个新模块(例如 pyopengl),我应该去哪里引入我在下载的文件夹中获得的所有文件夹?
- 从 PYTHONPATH 问题回来,我该如何配置 PYTHONPATH 以开始处理我的新模块?
推荐答案
PYTHONPATH
是一个环境变量- 是(见 https://unix.stackexchange.com/questions/24802/on-which-unix-distributions-is-python-installed-as-part-of-the-default-install)
/usr/lib/python2.7
在 Ubuntu 上- 您不应手动安装软件包.相反,请使用 pip.当一个包不在 pip 中时,它通常有一个 setuptools 安装脚本来安装包到正确的位置(见第 3 点).
- 如果您使用 pip 或 setuptools,则不需要显式设置
PYTHONPATH
PYTHONPATH
is an environment variable- Yes (see https://unix.stackexchange.com/questions/24802/on-which-unix-distributions-is-python-installed-as-part-of-the-default-install)
/usr/lib/python2.7
on Ubuntu- you shouldn't install packages manually. Instead, use pip. When a package isn't in pip, it usually has a setuptools setup script which will install the package into the proper location (see point 3).
- if you use pip or setuptools, then you don't need to set
PYTHONPATH
explicitly
如果您查看 pyopengl 的说明,您会发现它们是与第 4 点和第 5 点一致.
If you look at the instructions for pyopengl, you'll see that they are consistent with points 4 and 5.
这篇关于Linux 上的 Python 路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文