PythonPath环境变量不保存MACOS
运行 echo $PYTHONPATH
返回一个空行:
freddy@dave ~ % echo $PYTHONPATH
freddy@dave ~ %
echo $PATH
freddy@dave ~ % echo $PATH
/opt/homebrew/bin:/opt/homebrew/sbin: ...
为用户 freddy
返回正确的 .bash_profile
:
# Fig pre block. Keep at the top of this file.
export PATH="${PATH}:${HOME}/.local/bin"
eval "$(fig init bash pre)"
# Use Python 3.10, not homebrew
export PYTHONPATH="/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10"
export PATH="/opt/homebrew/bin:${PATH}"
source ~/.bash_profile
# Fig post block. Keep at the bottom of this file.
eval "$(fig init bash post)"%
为什么echo $PYTHONPATH
不返回任何内容?我如何将它分配给我的Python3.10路径?
- 我尝试重新启动,这对我运行
source ~/.bash_profile
没有帮助 - (这只是在执行后关闭终端?)
- 测试变量:
export TEST="TEST"
也回显空行
正如评论所暗示的那样,我正在尝试使用 Python3.10 而不是我的 Homebrew 安装,这是针对某些系统软件包的
Running echo $PYTHONPATH
returns a blank line:
freddy@dave ~ % echo $PYTHONPATH
freddy@dave ~ %
echo $PATH
returns properly
freddy@dave ~ % echo $PATH
/opt/homebrew/bin:/opt/homebrew/sbin: ...
.bash_profile
for user freddy
:
# Fig pre block. Keep at the top of this file.
export PATH="${PATH}:${HOME}/.local/bin"
eval "$(fig init bash pre)"
# Use Python 3.10, not homebrew
export PYTHONPATH="/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10"
export PATH="/opt/homebrew/bin:${PATH}"
source ~/.bash_profile
# Fig post block. Keep at the bottom of this file.
eval "$(fig init bash post)"%
Why does echo $PYTHONPATH
return nothing? And how do I assign it to my Python3.10 path?
- I've tried restarting, this does not help
- I've run
source ~/.bash_profile
(this just closes the terminal after execution though?) - A test variable:
export TEST="TEST"
also echos a blank line
As the comment suggests, I'm trying to use Python3.10 instead of my Homebrew installation, which is for some system packages
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用的是
zsh
,而不是bash
。我将
PYTHONPATH
移至.zshrc
,它现在保存为环境变量。但是,我选择了 pyenv 设置。并将以下内容添加到我的 .zshrc 文件中:
I am using
zsh
, notbash
.I moved
PYTHONPATH
to.zshrc
and it saves as an environment variable now.However, I have opted for the
pyenv
setup. And have added the following to my.zshrc
file: