简体   繁体   English

设置默认的python 2.7。

[英]Set default python 2.7.

I have just installed python 2.7 using macports as: 我刚刚使用macports将python 2.7安装为:

sudo port install py27-numpy py27-scipy py27-matplotlib py27-ipython +notebook py27-pandas py27-sympy py27-nose 须藤端口安装py27-numpy py27-scipy py27-matplotlib py27-ipython +笔记本py27-pandas py27-sympy py27-nose

during the process it found some issues, mainly broken files related with py25-haslib that I managed to fix. 在此过程中,它发现了一些问题,主要是我设法修复的与py25-haslib相关的损坏的文件。 Now it seems eveything is ok. 现在看来一切都还可以。 I tested a few programs and they run as expected. 我测试了一些程序,它们按预期运行。 Currently, I have two versions of python: 2.5 (Default, from when I worked in my former institution) and 2.7 (just installed): 当前,我有两个版本的python:2.5(默认值,从我在以前的机构工作时开始)和2.7(刚刚安装):

which python 哪个蟒蛇

/usr/stsci/pyssg/Python-2.5.1/bin/python /usr/stsci/pyssg/Python-2.5.1/bin/python

which python2.7 哪个python2.7

/opt/local/bin/python2.7 /opt/local/bin/python2.7

The next move would be set the new python version 2.7 as default: 下一步是将新的python版本2.7设置为默认值:

sudo port select --set python python27 sudo端口选择--set python python27

sudo port select --set ipython ipython27 sudo端口选择--set ipython ipython27

My question is: is there a way to go back to 2.5 in case something goes wrong? 我的问题是:如果出现问题,是否有办法回到2.5?

I know a priori, nothing has to go wrong. 我知道先验,没有什么要出错的。 But I have a few data reduction and analysis routines that work perfectly with the 2.5 version and I want to make sure I don´t mess up before setting the default. 但是我有一些数据缩减和分析例程可以与2.5版本完美配合,并且我想确保在设置默认值之前不会弄乱。

if you want to revert, you can modify your .bash_profile or other login shell initialization to fix $PATH to not add "/Library/Frameworks/Python.framework/Versions/2.5/bin" to $PATH and/or to not have /usr/local/bin appear before /usr/bin on $PATH. 如果要还原,可以修改.bash_profile或其他登录Shell初始化以修复$ PATH,以不将“ /Library/Frameworks/Python.framework/Versions/2.5/bin”添加到$ PATH和/或不包含/ usr / local / bin出现在$ PATH上的/ usr / bin之前。

If you want to permanently remove the python.org installed version, paste the following lines up to and including the chmod into a posix- compatible shell: 如果要永久删除python.org安装的版本,请将以下行粘贴至chmod并包括在posix兼容的shell中:

tmpfile=/tmp/generate_file_list
cat <<"NOEXPAND" > "${tmpfile}"
#!/bin/sh
version="${1:-"2.5"}"
file -h /usr/local/bin/* | grep \
"symbolic link to ../../../Library/Frameworks/Python.framework/"\
"Versions/${version}" | cut -d : -f 1
echo "/Library/Frameworks/Python.framework/Versions/${version}"
echo "/Applications/Python ${version}"
set -- Applications Documentation Framework ProfileChanges \
         SystemFixes UnixTools
for package do
  echo "/Library/Receipts/Python${package}-${version}.pkg"
done
NOEXPAND
chmod  ug+x ${tmpfile}

...excripted from troubleshooting question on python website ...摘自python网站上的疑难解答问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM