python - 如何在 FreeBSD 中默认设置 Python 版本?

标签 python environment-variables freebsd

我正在尝试安装应用程序 node ,但在我的环境中默认情况下是 python 3,并且需要 python 2.6。我如何更改 FreeBSD 中的默认 python 版本?

# cd /usr/local/bin
# ls -l | grep python
-r-xr-xr-x   2 root  wheel  1246256 Jul 12  2011 python
-r-xr-xr-x   2 root  wheel     1401 Jul 12  2011 python-config
-r-xr-xr-x   2 root  wheel     6060 Jul 12  2011 python-shared
-r-xr-xr-x   2 root  wheel     1408 Jul 12  2011 python-shared-config
-r-xr-xr-x   1 root  wheel     3720 Jul 12  2011 python-shared2.6
-r-xr-xr-x   1 root  wheel     1431 Jul 12  2011 python-shared2.6-config
-r-xr-xr-x   2 root  wheel     6060 Jul 12  2011 python-shared3.1
-r-xr-xr-x   2 root  wheel     1408 Jul 12  2011 python-shared3.1-config
-r-xr-xr-x   1 root  wheel  1182056 Jul 12  2011 python2.6
-r-xr-xr-x   1 root  wheel     1424 Jul 12  2011 python2.6-config
-r-xr-xr-x   2 root  wheel  1246256 Jul 12  2011 python3.1
-r-xr-xr-x   2 root  wheel     1401 Jul 12  2011 python3.1-config

最佳答案

您应该删除 python 元端口 /usr/ports/lang/python。 然后在/etc/make.conf中设置如下变量:

PYTHON_DEFAULT_VERSION='python3.2'

(如果你想要最新版本。或者你也可以使用python3.1。目前,默认是python2.7。)

现在再次安装/usr/ports/lang/python。 请注意,ports 可以请求另一个版本的 python!

更新:自 2013 年 10 月起,有一种设置默认版本的新方法;

20131003:
  AFFECTS: users of lang/python* and ports
  AUTHOR: mva@FreeBSD.org

  The default versions of lang/python* have been changed to support the
  new DEFAULT_VERSIONS variable.

  PYTHON_DEFAULT_VERSION, PYTHON2_DEFAULT_VERSION and
  PYTHON3_DEFAULT_VERSION are deprecated. If you have set them in your
  make.conf, you should change them something like

  DEFAULT_VERSIONS=python=2.7 python2=2.7 python3=3.3

关于python - 如何在 FreeBSD 中默认设置 Python 版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9349831/

相关文章:

python - 如何将 tf.while_loop() 用于 tensorflow 中的可变长度输入?

python - 在没有 NAN 的情况下将 Pandas DF 转换为 JSON

docker - Docker撰写-环境变量包含点

python-3.x - 使用 pyyaml 从 yaml 解析环境变量

php - 在 freeBSD 上设置 PHP 与 MySQL 一起工作?

linux - 用户空间桥接 - Linux 与 FreeBSD

python - 在每次 SVN 提交时自动更新 setup.py 版本

python - 图.transFigure.transform() : lines in figure coordinates do not scale with the figure

node.js - 为什么我的 'npm start' 脚本导致错误 : '.' is not recognized as an internal or external command, 可运行程序或批处理文件。?

c - 如何从 parent 向 child 发送信号 SIGUSR1 和 SIGUSR2?