设置pythonpath有两个不同的版本

2024-06-09 13:37:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在开发一个CentOS 6.5,它有Python2.6.6,我还安装了Python2.7.5

问题是我想导入qgis并使用Python2.7.5。在

如果我写

from qgis.core import *

没有问题,但是当我尝试使用python2.7时,输入scl enable python27 bash和impro,它返回的moudle

^{pr2}$

有什么帮助吗?我尝试在PYTHONPATH中添加qgis的安装路径,但是没有成功


Tags: fromcoreimport路径bashenablepython27centos
1条回答
网友
1楼 · 发布于 2024-06-09 13:37:28

如果需要在同一台计算机上支持多个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

相关问题 更多 >