문제

I ran the example from here; http://conda.pydata.org/docs/index.html

I'm on a Mac, 10.8.5. I might definitely have squashed something because I initially had troubles with my Anaconda, but I thought it was now working. Just to sanity check, I ran the example shown in the help, above. It merely creates a new conda environment with an older numpy version and then shows how source activate [env] can get the preferred item.

In my case, everything seemed to run fine, but the version of numpy stayed the same. Any thoughts? Thank you so much in advance!

$ ~/anaconda/bin/python2.7
Python 2.7.6 |Anaconda 1.9.2 (x86_64)| (default, Jan 10 2014, 11:23:15)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
nu>>> numpy.__version__
'1.8.1'
>>> quit()

$ conda create -p ~/anaconda/envs/trynum16 numpy=1.6 anaconda

$ source activate ~/anaconda/envs/trynum16
discarding ~/anaconda/bin from PATH
prepending ~/anaconda/envs/trynum16/bin to PATH

(~/anaconda/envs/trynum16):~ $ echo $PATH
~/anaconda/envs/trynum16/bin:/usr/local/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/bin

(~/anaconda/envs/trynum16):~ $ python
Python 2.7.5 |Anaconda 1.8.0 (x86_64)| (default, Oct 24 2013, 07:02:20)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> import numpy
>>> numpy.__version__
'1.8.1'
>>> quit()

(~/anaconda/envs/trynum16):~ $ echo $PATH
~/anaconda/envs/trynum16/bin:/usr/local/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/bin

(~/anaconda/envs/trynum16):~ $ source deactivate
discarding ~/anaconda/envs/trynum16/bin from PATH

$ echo $PATH
~/anaconda/bin:/usr/local/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/bin
도움이 되었습니까?

해결책

OK, it was user error. My top level python, non-Anaconda, had a numpy and it was being picked up in the path first! To determine the conflict and fix it, I did the following.

# Start from Non-Anaconda or Root Python environment
$ source deactivate
$ conda info -e
# conda environments:
trynum16                 ~/anaconda/envs/trynum16
root                  *  ~/anaconda

$ which python
/usr/local/bin/python

$ echo $PATH
/usr/local/bin:~/anaconda/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/bin

# Amongst many other items, see the 'offending' numpy here
$ pip freeze
numpy==1.8.1

# Without Sudo, got error,
$ pip uninstall numpy
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/bson/__init__.py'
# So did Sudo, probably my mistake on the install?
$ sudo pip uninstall numpy

$ source activate ~/anaconda/envs/trynum16
$ conda info -e
# conda environments:
trynum16              * ~/anaconda/envs/trynum16
root                    ~/anaconda
$ python
Python 2.7.6 |Continuum Analytics, Inc.| (default, Jan 10 2014, 11:23:15)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
>>> import numpy
>>> numpy.__version__
'1.6.2'

After doing that, two separate conda environments with different versions work fine. Here is how the second is done.

Pre-checks: 1.See what versions of Numpy exist at all on PYPI: https://pypi.python.org/pypi/numpy .
That page shows only the latest, so look here for historical items; Download URL: http://sourceforge.net/projects/numpy/files/NumPy/

2.See what versions of Numpy are on Binstar; https://binstar.org/search?q=numpy

# 3.Which NumPy versions have official, public Conda packages?
$ conda search numpy
Fetching package metadata: ...
numpy                        1.5.1                    py27_0  defaults
#...etc

# This old version Conflicted with Anaconda, so removed that part.
$ conda create -p ~/anaconda/envs/trynum15 numpy=1.5.1
$ source activate /Users/amoroney/anaconda/envs/trynum15
$ conda info -e
# conda environments:
trynum15              *  ~/anaconda/envs/trynum15
trynum16                 ~/anaconda/envs/trynum16
root                     ~/anaconda

$ python
>>> import numpy
>>> numpy.__version__
'1.5.1'
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top