How do I “repeatedly uninstall numpy” safely? Why was this necessary?

帅比萌擦擦* 提交于 2019-12-11 08:17:50

问题


Following directions in http://sfepy.org/doc-devel/installation.html#installing-sfepy I installed SfePy to my Python 2.7 anaconda using

conda install -c conda-forge sfepy

Immediately after that, I can no longer import numpy

>>> import numpy as np
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/david/anaconda2/lib/python2.7/site-packages/numpy/__init__.py", line 142, in <module>
    from . import core
  File "/Users/david/anaconda2/lib/python2.7/site-packages/numpy/core/__init__.py", line 91, in <module>
    raise ImportError(msg.format(path))
ImportError: Something is wrong with the numpy installation. While importing we 
detected an older version of numpy in ['/Users/david/anaconda2/lib/python2.7/site-packages/numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.

I see that there is some advice included at the very end of the message:

One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.

Question(s):

  1. How exactly do I "repeatedly uninstall numpy" safely? This answer mentions conda remove --force but that sounds scary to me.
  2. Once "none is found" would conda install -c conda-forge sfepy again reinstall one good numpy?
  3. Why might this have happened? Might it reflect some underlying serious problem, or is it just "one of those things" and I should just "repeatedly uninstall numpy" and move on with my life?

回答1:


Repeatedly uninstalling numpy would normally be for when you used pip to install. Because you are using Conda, trying to conda uninstall numpy will remove numpy and any package that depends on numpy (and any package that depends on those, etc).

Generally, this means you will break your environment. The whole point of using Conda is to create new, isolated environments so that you don't have to worry about what you are running into: package collision.

The steps you should take are:

  1. Uninstall Anaconda, it looks like you may have borked your base installation. Also, GET OFF PYTHON 2.7!

  2. Reinstall Anaconda, preferably with Python 3.6 or higher.

  3. Use conda to create an isolated environment for you to work in. conda create -n finite python=3.6 sfepy numpy pandas ipython

  4. Activate and use that environment to do your work in finite analysis. conda activate finite



来源:https://stackoverflow.com/questions/55944472/how-do-i-repeatedly-uninstall-numpy-safely-why-was-this-necessary

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!