问题
I can't, for the life of me, get dolfin
running 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
回答1:
(Spyder maintainer here) Since Spyder 3.3.1 (to be released in a couple of days), the solution is the following:
Activate your environment
Install the
spyder-kernels
package there, with the following command:conda install spyder-kernels=0.*
Also run there (in a system terminal)
python -c "import sys; print(sys.executable)"
and copy the path returned by that command.
Deactivate your environment and start Spyder from your root or base one.
Go to
Tools > Preferences > Python Interpreter > Use the following interpreter
and paste there the path you got in step 3.
Start a new IPython console and run
from dolfin import *
It should work now.
来源:https://stackoverflow.com/questions/51466931/no-module-named-dolfin-using-spyder