Question: ViennaRNA and Python
gravatar for tfadgreef
6.3 years ago by
tfadgreef0 wrote:

Dear all,

I recently compiled ViennaRNA 2.1.7 using the following options:

./configure --prefix=/usr/local/ViennaRNA --with-python


sudo make install

However, when I open Python and I type: 

import RNA

I get the following error: ImportError: No module named _RNA

What is going wrong?

Thank you.

viennrna python • 6.0k views
ADD COMMENTlink modified 21 months ago by moustafa.ismail20 • written 6.3 years ago by tfadgreef0

The use of --prefix=/usr/local/ViennaRNA is non-standard. Simply using --prefix=/usr/local (which is also the default) would have done the trick since /usr/local/lib/python... should already be in your PYTHON_PATH

ADD REPLYlink modified 8 months ago by RamRS30k • written 6.3 years ago by Andreas2.5k
gravatar for Devon Ryan
6.3 years ago by
Devon Ryan96k
Freiburg, Germany
Devon Ryan96k wrote:

I'm guessing that /usr/local/ViennaRNA isn't in your PYTHONPATH. So either change that or just:

import sys

It's likely that the python stuff is in a subdirectory, so modify as needed.

ADD COMMENTlink modified 8 months ago by RamRS30k • written 6.3 years ago by Devon Ryan96k
gravatar for moustafa.ismail
21 months ago by
moustafa.ismail20 wrote:

For future reference, since there is not much help for the ViennaRNA-2.4.10 package:

I ran into this error after installing the package with the python3 interface. I found a fix for me:

Go to the directory: /usr/local/lib/python3.5/site-packages you should find the directory /RNA which should contain the file that tells python to consider this directory for importing a library.

You should also find a .so file, rename that file to be _RNA.sosee:

A common error received by first-time users is the following:

>>> import example 
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "", line 2, in ?
import _example
ImportError: No module named _example

If you get this message, it means that you either forgot to compile the wrapper code into an extension module or you didn't give the extension module the right name. Make sure that you compiled the wrappers into a module called And don't forget the leading underscore (_).

This solved my import error. Hope this helps

ADD COMMENTlink written 21 months ago by moustafa.ismail20
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1442 users visited in the last hour