PyCharm:如何调用frameworkpython,以便它将使用framework python而不是virtualenv python? [英] PyCharm: How do I call frameworkpython so that it will use the framework python instead of the virtualenv python?

查看:54
本文介绍了PyCharm:如何调用frameworkpython,以便它将使用framework python而不是virtualenv python?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的virtualenv中使用了matplotlib库.如果以这种方式使用它,则matplotlib将不会绘制图形,因为它不是python框架,而是根据virtualenv编写的python.该问题已记录在matplotlib网站上:

我决定使用他们的第二种解决方法,即将函数PYTHONHOME包含到我的bashrc中.文件.

我已将以下功能包括在matplotlib网站上的bashrc中:

 功能框架python {如果 [[ !-z"$ VIRTUAL_ENV"]];然后PYTHONHOME = $ VIRTUAL_ENV/usr/local/bin/python"$ @"别的/usr/local/bin/python"$ @"科幻} 

现在,要成功运行matplotlib,我需要调用 frameworkpython 而不是 python 来绘制图形.在我的终端中,这一切都很好,我只需在其中键入命令,但我宁愿使用PyCharm来运行我的python代码.

我的问题是,每次按下绿色的播放按钮时,如何让PyCharm运行 frameworkpython ?绿色的播放按钮仅调用 python .

我单击了编辑配置...",但看不到如何更改它.您可以更改解释器,但frameworkpython不是解释器,而是bashrc文件中的函数.

解决方案

您可以在Pycharm中设置Python解释器.看: https://www.jetbrains.com/help/pycharm/2016.1/configuring-available-python-interpreters.html

I'm using matplotlib library with my virtualenv. If you use it this way, matplotlib will not plot the graph because it is not the python framework, but the python as per the virtualenv. This problem has been documented on the matplotlib website: http://matplotlib.org/faq/virtualenv_faq.html

You will end up with this error if you try running it with just the virtualenv python:

Python is not installed as a framework

I decided to use their second workaround which is to include the function PYTHONHOME into my bashrc. file.

I have included the function below into bashrc taken off the matplotlib website:

function frameworkpython {
    if [[ ! -z "$VIRTUAL_ENV" ]]; then
        PYTHONHOME=$VIRTUAL_ENV /usr/local/bin/python "$@"
    else
        /usr/local/bin/python "$@"
    fi
}

Now, to run matplotlib successfully, I need to call frameworkpython instead of python to draw the graph. This is all good in my Terminal where I just type in the commands but I would rather use PyCharm to run my python code.

My question is, how do I get PyCharm to ran frameworkpython each time I press the green play button? The green play button just calls python.

I clicked on "Edit Configurations..." but cannot see how to change this. You can change the interpreters but frameworkpython is not an interpreter but rather a function within the bashrc file.

解决方案

You can set your Python interpreter in Pycharm. See: https://www.jetbrains.com/help/pycharm/2016.1/configuring-available-python-interpreters.html

这篇关于PyCharm:如何调用frameworkpython,以便它将使用framework python而不是virtualenv python?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆