3

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?
James
  • 32,991
  • 4
  • 47
  • 70
uhoh
  • 3,713
  • 6
  • 42
  • 95

1 Answers1

5

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

James
  • 32,991
  • 4
  • 47
  • 70
  • This sounds like a much better approach than `conda remove --force` (found [here](https://stackoverflow.com/a/38463294/3904031), just recently added to question), and as I no longer have my old external constraint to use 2.7, why don't I take this opportunity to follow your advice and "get off 2.7" today! – uhoh May 02 '19 at 02:00
  • @uhoh Yeah, I want to strongly second the recommendation to use isolated envs more. I'd even go further and say: avoid Anaconda altogether, switch to Miniconda, and don't install anything in **base** other than essential infrastructure. In my experience, this really helps to mitigate against broken Conda configurations. And if you really do depend on the full scale Anaconda distribution, you can created a dedicated env for it. – merv May 02 '19 at 02:20
  • @merv these are good suggestions! I'll give the Ana vs Mini and minimal base some thought. – uhoh May 02 '19 at 02:27