使用 Bash 修复 Python 库的 PATH
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/58051467/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Fixing PATH for Python libraries using Bash
提问by The Pointer
I am attempting to install some Python libraries by executing variations of the following command in Bash:
我试图通过在 Bash 中执行以下命令的变体来安装一些 Python 库:
pip install --user -U numpy
I installed Python3 using Homebrew.
我使用 Homebrew 安装了 Python3。
I then get variations of the following message each time:
然后我每次都会收到以下消息的变体:
WARNING: The scripts f2py, f2py3 and f2py3.7 are installed in '/Users/x/Library/Python/3.7/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
警告:脚本 f2py、f2py3 和 f2py3.7 安装在不在 PATH 上的“/Users/x/Library/Python/3.7/bin”中。考虑将此目录添加到 PATH,或者,如果您希望取消此警告,请使用 --no-warn-script-location。
I want to fix this issue to avoid problems in the future. I would greatly appreciate it if people could please take the time to explain how to do this.
我想解决这个问题以避免将来出现问题。如果人们能花时间解释如何做到这一点,我将不胜感激。
回答by Dylan McNamee
The error message is telling you to add /Users/you/Library/Python/3.7/bin to your path.
错误消息告诉您将 /Users/you/Library/Python/3.7/bin 添加到您的路径中。
To do that, use a text editor to open /Users/you/.bashrc
, and as the very last line add:
为此,请使用文本编辑器打开/Users/you/.bashrc
,并在最后一行添加:
export PATH=/Users/you/Library/Python/3.7/bin:$PATH
Then you'll need to launch a new Terminal window for those settings to take effect. (you could make it take effect in your current shell by entering the line directly into your shell)
然后您需要启动一个新的终端窗口以使这些设置生效。(您可以通过直接在您的 shell 中输入该行来使其在您当前的 shell 中生效)