1、我有一个新的linux,python=python2.7和python3=python3.4
2、我使用git安装了pyenv
3、我使用 pyenv 安装了 anaconda3-4.1.1 并使用 pyenv global anaconda3-4.1.1 通过 pyenv 将其设置为全局
4、我使用pyenv virtualenv anaconda3-4.1.1 mytestenv创建了一个virtualenv
5、我使用import numpy来测试结果。在原始的 anaconda3-4.1.1环境中,可以导入 numpy,但在mytestenv 环境中没有 numpy。
请查看以下详细信息:
(anaconda3-4.1.1) giza@DESKTOP-H8KC9QC:~$ pyenv versions
system
* anaconda3-4.1.1 (set by /home/giza/.pyenv/version)
(anaconda3-4.1.1) giza@DESKTOP-H8KC9QC:~$ pyenv virtualenv anaconda3-4.1.1 mytestenv
Fetching package metadata .......
Solving package specifications: ..........
Package plan for installation in environment /home/giza/.pyenv/versions/anaconda3-4.1.1/envs/mytestenv:
The following NEW packages will be INSTALLED:
openssl: 1.0.2j-0
pip: 8.1.2-py35_0
python: 3.5.2-0
readline: 6.2-2
setuptools: 27.2.0-py35_0
sqlite: 3.13.0-0
tk: 8.5.18-0
wheel: 0.29.0-py35_0
xz: 5.2.2-0
zlib: 1.2.8-3
Linking packages ...
[ COMPLETE ]|##########################################################################################################| 100%
#
# To activate this environment, use:
# $ source activate mytestenv
#
# To deactivate this environment, use:
# $ source deactivate
#
Installing pip from https://bootstrap.pypa.io/get-pip.py...
Requirement already up-to-date: pip in /home/giza/.pyenv/versions/anaconda3- 4.1.1/envs/mytestenv/lib/python3.5/site-packages
(anaconda3-4.1.1) giza@DESKTOP-H8KC9QC:~$ pyenv activate mytestenv
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
(mytestenv) giza@DESKTOP-H8KC9QC:~$ python
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'numpy'
>>> exit()
(mytestenv) giza@DESKTOP-H8KC9QC:~$ pyenv deactivate
(anaconda3-4.1.1) giza@DESKTOP-H8KC9QC:~$ python
Python 3.5.2 |Anaconda 4.1.1 (64-bit)| (default, Jul 2 2016, 17:53:06)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> exit()
(anaconda3-4.1.1) giza@DESKTOP-H8KC9QC:~$