简体   繁体   English

安装本地版本的Python

[英]Installing Local Version of Python

I'm trying to install my own version of Python that is independent of the system one on my Mac. 我正在尝试安装自己的Python版本,该版本独立于Mac上的系统。 Basically, I'm following this Machine Learning Tutorial . 基本上,我正在遵循《 机器学习教程》 I'm in step 4.4 where I'm trying to run the command "python create_lmdb.py" in the command-line, but I get an error saying opencv module not found. 我在步骤4.4中尝试在命令行中运行命令“ python create_lmdb.py”,但遇到一条错误消息,提示找不到opencv模块。

So, then I found the latest openCV Tutorial for Sierra to install openCV properly. 因此,然后我找到了Sierra的最新openCV教程 ,以正确安装openCV。 I am in step 2 and 3 where I've tried to edit the /.bash_profile with "export PATH=/usr/local/bin:$PATH". 我在步骤2和3中尝试使用“ export PATH = / usr / local / bin:$ PATH”编辑/.bash_profile。 I've saved and opened the file to confirm that the file changed. 我已保存并打开文件以确认文件已更改。 I continued with the tutorial, but when I get to "which python" I find that Python is still the system version with the file path of /usr/bin/python rather than /usr/local/bin/python. 我继续了本教程,但是当我进入“哪个python”时,我发现Python仍然是系统版本,文件路径为/ usr / bin / python而不是/ usr / local / bin / python。

I've spent 3 days on this problem. 我已经花了3天的时间解决这个问题。 I've searched around on here and tried various solutions. 我在这里搜索并尝试了各种解决方案。 I've contacted Apple, but they of course couldn't help...or wouldn't. 我已经联系了苹果公司,但他们当然无济于事...或者不会。 Googled like crazy. 谷歌疯狂。 I've tried installing a different distribution of Python. 我尝试安装其他发行版的Python。 I've tried uninstalling and reinstalling Python. 我尝试卸载并重新安装Python。

Thanks in advance for any help. 在此先感谢您的帮助。

In essence, this is something that you don't want to change. 本质上,这是您不希望更改的事情。 For various reasons changing what your system believes to be "python" is not ideal. 由于各种原因,更改系统认为是“ python”的内容并不理想。 A more detailed anser can be found here , but for those that don't want to click through all you need to do is create a bash alias to the path you desire. 可以在此处找到更详细的分析器,但是对于那些不想单击所有您需要做的事情,请为所需的路径创建一个bash别名。

ie alias py=/usr/bin/python3 or whatever the actual path is. alias py=/usr/bin/python3或任何实际路径。

我建议您通读详尽的指南,以在OS X上设置Python(以及可选的其他评论者建议的虚拟环境)。

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

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