我正在运行miniconda2(python2.7 安装)。我没有尝试并排使用miniconda3 ,而是尝试创建一个 python3.5 环境。但是,当我尝试导入 numpy 时出现错误,因为 python 尝试为 python2.7 加载 numpy。我假设这是因为我设置的环境变量.bashrc
指向miniconda2安装。
解决此问题的最佳方法是什么?有没有办法可以并排使用 conda python2 和 python3 ?
我的.bashrc
有:
export PYTHONLIB="/home/exacloud/lustre1/CompBio/miniconda2/lib"
export PYTHONPATH="/home/exacloud/lustre1/CompBio/miniconda2/lib/python2.7/site-packages"
export PYTHONUSERBASE="/home/exacloud/lustre1/CompBio/miniconda2"
export CONDA_BIN="/home/exacloud/lustre1/CompBio/miniconda2/bin"
会议:
balter@s-3-5:~$ conda create -n p3 python=3 pandas numpy
Fetching package metadata .............
Solving package specifications: ..........
Package plan for installation in environment /<path>/miniconda2/envs/p3:
The following NEW packages will be INSTALLED:
blas: 1.1-openblas conda-forge
ca-certificates: 2016.8.31-0 conda-forge
certifi: 2016.8.31-py35_0 conda-forge
libgfortran: 3.0.0-1
ncurses: 5.9-9 conda-forge
numpy: 1.11.2-py35_blas_openblas_200 conda-forge [blas_openblas]
openblas: 0.2.18-5 conda-forge
openssl: 1.0.2h-2 conda-forge
pandas: 0.19.0-np111py35_0 conda-forge
pip: 8.1.2-py35_0 conda-forge
python: 3.5.2-2 conda-forge
python-dateutil: 2.5.3-py35_0 conda-forge
pytz: 2016.7-py35_0 conda-forge
readline: 6.2-0 conda-forge
setuptools: 26.1.1-py35_0 conda-forge
six: 1.10.0-py35_1 conda-forge
sqlite: 3.13.0-1 conda-forge
tk: 8.5.19-0 conda-forge
wheel: 0.29.0-py35_0 conda-forge
xz: 5.2.2-0 conda-forge
zlib: 1.2.8-3 conda-forge
Proceed ([y]/n)? y
Linking packages ...
[ ]| [ca-certificates ]| [libgfortran ]|#### [ncurses ]|######## [sqlite ]|############# [tk ]|################# [openblas ]|####################### | 33%
Screen session on s (system load: 1.12 1.05 0.91) Thu 27.10.2016 14:43
wheel: 0.29.0-py35_0 conda-forge
xz: 5.2.2-0 conda-forge
zlib: 1.2.8-3 conda-forge
Proceed ([y]/n)? y
Linking packages ...
[ ]| [ca-certificates ]| [libgfortran ]|#### [ncurses ]|######## [sqlite ]|############# [tk ]|################# [openb[ COMPLETE ]|######################################################################| 100%
No psutil available.
To proceed, please conda install psutil#
# To activate this environment, use:
# $ source activate p3
#
# To deactivate this environment, use:
# $ source deactivate
#
balter@s-3-5:~$
balter@s-3-5:~$ source activate p3
(p3) balter@s-3-5:~$ python
Python 3.5.2 | packaged by conda-forge | (default, Jul 26 2016, 01:32:08)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/<path>/miniconda2/lib/python2.7/site-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/<path>/miniconda2/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/<path>/miniconda2/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/<path>/miniconda2/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/<path>/miniconda2/lib/python2.7/site-packages/numpy/core/__init__.py", line 14, in <module>
from . import multiarray
ImportError: dynamic module does not define module export function (PyInit_multiarray)
>>>