虚拟环境使用Python3代替Python 2.7

时间:2018-09-10 14:23:16

标签: python virtualenv

我已经创建了一个虚拟环境,并且每当我运行以下命令时,在终端上,Python3就会默认启动。

<li class="dropdown">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{% if app.request.locale == 'ru' %}Russian{% else %}English{% endif %} <span class="caret"></span></a>
    <ul class="dropdown-menu">

        {# Check if there is a route and some parameters in the request #}
        {% if app.request.get('_route') is not empty and app.request.get('_route_params') is not null %}

            {# English #}
            <a href="{{ path(app.request.get('_route'), app.request.get('_route_params')|merge({'_locale': 'en'})) }}">English</a>
            {# Russian #}
            <a href="{{ path(app.request.get('_route'), app.request.get('_route_params')|merge({'_locale': 'ru'})) }}">Russian</a>

        {# If there is no route in the request, redirect to the homepage #}
        {% else %}

            {# English #}
            <a href="{{ path('homepage', {'_locale': 'en'}) }}">English</a>
            {# Russian #}
            <a href="{{ path('homepage', {'_locale': 'ru'}) }}">Russian</a>

        {% endif %}
    </ul>
</li>

有人可以告诉我如何解决此问题。

1 个答案:

答案 0 :(得分:0)

为了阻止python立即激活,请不要使用“ env / bin / python”,而应使用“ env / bin / activate”

如果希望环境为其他版本,则必须在环境创建期间调用该版本。例如,假设它是系统上的有效命令,请使用:python2而不是python或python3。

有关如何执行此操作的更多信息:How to specify python version used to create Virtual Environment?