Skip to main content
 首页 » 编程设计

python之我的 .bash_profile 文件应该放在哪里供 Python 更新

2024年11月01日8bhlsheji

我正在使用 Mac OSX 10.6.8 Snow Leopard,我认为我已经拥有安装 Python 3.3.2 所需的一切,但是当我在终端中键入 python 时,它仍然说我有2.6.1.这是因为它找不到更新版本的路径,应该通过将以下内容添加到 .bash_profile 来解决这个问题:

PATH="/Library/Frameworks/Python.framework/Versions/3.3.2/bin:${PATH}" 
export PATH 

我已经完成了(并多次运行 cat 命令来检查),但它一直在说同样的话。我想我的 .bash_profile 文件和/或 Python 3.3.2 文件夹可能不在正确的目录中? .bash_profile 位于 /Users/mac(主页),Python 文件夹位于 /Library/Frameworks/Python.framework/Versions。他们应该在别的地方吗?

提前致谢!

请您参考如下方法:

使用python3运行python3,修改.bash_profile或执行source .bash_profile后重启shell > 在不重新启动 shell 的情况下加载新设置。

$ which python3 
/usr/bin/python3 

例子:

$ cat so.py 
#!/usr/bin/python3 
print("hello, world!") 
$ chmod +x so.py 
$ ./so.py 
hello, world!