4

I can't, for the life of me, get dolfinrunning with Spyder. That's what I thought at first. I managed to get it running somehow, but not in a convenient way. Here is the situation:

The error

conda activate fenics, spyder, from dolfin import *: No module named 'dolfin'.

What works

  • conda activate fenics, python, from dolfin import *: worked in the first place.
  • conda activate fenics, ipython, from dolfin import *: worked after some tweaking.
  • conda activate fenics, spyder, from dolfin import *: worked after some tweaking.

What I've done so far

I installed anaconda using the suggested download from conda.

Running conda create -n fenics -c conda-forge fenics, conda install fenics and conda activate fenics to install and activate the fenics environment.

Then starting python and executing from dolfin import * works. :)

Running the same command in ipython doesn't work. Using conda list I found out that

    ...
    hdf5
    hypre
    icu
    isl
    jedi
    ...

there is no ipython in the list and which with python and ipthon yields

    /home/hannes/anaconda3/envs/fenics/bin/python
    /home/hannes/anaconda3/bin/python

Thus, conda install ipython, ipython and from dolfin import * works as well! :)

Running spyder and from dolfin import * throws the same error as with ipython before: No module named 'dolfin'. Maybe spyder isn't available in fenics' environment as well? conda list ... nope, not there. Now begins the fun part ... :(. conda install spyder and which spyder yields

    /home/hannes/anaconda3/envs/fenics/bin/spyder

However, running spyder throws the error

    libGL error: unable to load driver: r600_dri.so
    libGL error: driver pointer missing
    libGL error: failed to load driver: r600
    libGL error: unable to load driver: r600_dri.so
    libGL error: driver pointer missing
    libGL error: failed to load driver: r600
    libGL error: unable to load driver: swrast_dri.so
    libGL error: failed to load driver: swrast
    Segmentation fault (core dumped)

That seems to be some opengl issues. The solution from github issue 6968, conda install pyopengl, didn't help :(; still the same libGL errors. Therefore, conda uninstall spyder, spyder at least gave me back spyder.

My best clue so far

I tried adding the module to PYTHONPATH by adding

    export PYTHONPATH="$PYTHONPATH:/home/hannes/anaconda3/envs/fenics/lib/python3.6/site-packages/"

to .bashrc and running a Spyder that is not inside the fenics environment. No success, although I am not sure whether I did this step correctly. Why, conda activate fenics, spyder and sys.path spits out:

    /home/hannes/anaconda3/lib/python3.6/site-packages/spyder
    /home/hannes/anaconda3/lib/python36.zip
    /home/hannes/anaconda3/lib/python3.6
    /home/hannes/anaconda3/lib/python3.6/lib-dynload
    /home/hannes/.local/lib/python3.6/site-packages
    /home/hannes/anaconda3/lib/python3.6/site-packages
    /home/hannes/anaconda3/lib/python3.6/site-packages/IPython/extensions
    /home/hannes/.ipython

Since that didn't work I got from dolfin import * working after running conda activate fenics, ipython

    import sys
    sys.path.append('/home/hannes/anaconda3/envs/fenics/lib/python3.6/site-packages')

Since this is only a temporarily workaround (I have to add it every time I start Spyder) I am interested in a permanent fix.

I'd appreciate any help :).

Hannes

Hannes
  • 73
  • 1
  • 6

1 Answers1

2

(Spyder maintainer here) Since Spyder 3.3.1 (to be released in a couple of days), the solution is the following:

  1. Activate your environment

  2. Install the spyder-kernels package there, with the following command:

    conda install spyder-kernels=0.*

  3. Also run there (in a system terminal)

    python -c "import sys; print(sys.executable)"

    and copy the path returned by that command.

  4. Deactivate your environment and start Spyder from your root or base one.

  5. Go to

    Tools > Preferences > Python Interpreter > Use the following interpreter

    and paste there the path you got in step 3.

  6. Start a new IPython console and run

    from dolfin import *

    It should work now.

Carlos Cordoba
  • 33,273
  • 10
  • 95
  • 124
  • Thanks for the quick reply. When will "in a couple of days" be?^^ Is there some way I can keep track of the upcoming update? – Hannes Jul 22 '18 at 17:50
  • 1
    It should be available on July 26 or 27. Spyder informs automatically of such updates to its users, unless you deactivated that mechanism in the past. If you did it, you can reactivate it by going to `Tools > Preferences > General > Advanced Settings` and selecting the option called `Check for updates on startup`. – Carlos Cordoba Jul 22 '18 at 22:53
  • 1
    Yes, it finally worked :). Thank you so much for your help :). – Hannes Oct 24 '18 at 21:34