【问题标题】:Set pythonpath having two different versions设置具有两个不同版本的pythonpath
【发布时间】:2016-10-10 19:05:16
【问题描述】:

我正在使用具有 Python 2.6.6 的 CentOS 6.5,并且我还安装了 Python 2.7.5

问题是我想导入 qgis 并使用 Python 2.7.5。

如果我写的话,在 python 2.6.6 中

from qgis.core import *

没有问题,但是当我通过键入 scl enable python27 bash 并导入它返回的 moudle 尝试使用 Python 2.7 时

from qgis.core import *
Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
ImportError: No module named qgis.core

有什么帮助吗?我尝试将安装 qgis 但不起作用的路径添加到 PYTHONPATH 中

【问题讨论】:

    标签: python python-2.7 unix qgis


    【解决方案1】:

    如果您需要在同一台计算机上支持多个 Python 和多个应用程序,请使用 Python 虚拟环境:

    https://packaging.python.org/en/latest/installing/#creating-virtual-environments

    创建虚拟环境并在其中安装 qgic 的示例:

      virtualenv -p python2.7 venv  # Create Python installation in venv folder
      source venv/bin/activate  # Activate this environment
      pip install qgis   # Replace this with installation instructions from qgis package
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-02-27
      • 1970-01-01
      • 1970-01-01
      • 2016-12-23
      • 2020-11-29
      • 2018-11-25
      • 2012-12-04
      • 2020-10-24
      相关资源
      最近更新 更多