This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Installing and importing viennaRNA to python in windows

Hello, I've tried to install and import viennaRNA python package on a windows computer in many different ways, but none of them succeeded. (eventually I always get to 'no module named 'RNA'' message). Do anyone know what will be the right way to do so? I could not find any detailed guide. Alternatively, are there any other good python packages that calculates RNA MFE? Thank you!

rna python viennarna

I think we're going to need more information to be able to help. Doing this on windows complicates things a bit.

  • How did you install python? And what version(s)?
  • Do you have only a single python installation?
  • How did you install viennaRNA
  • What is the exact code you're trying to import with?
  • What are the precise error messages you get?

I'm using python 3.6 (anaconda) and pycharm. I've tried to use the windows installer from https://www.tbi.univie.ac.at/RNA/index.html#pack_windows - the installer finished successfully but it had no effect on my python (still could not import the package). I've looked for a conda installation for this package but it is not suitable for windows. I tried to look for a pip installation but could not find such. I also tried to download the package directly from github (https://github.com/ViennaRNA/ViennaRNA) but could not find a way to install it from the files I got (the instructions only refers to linux installaions). Bottom line every time i try to import the package with 'import RNA' I get 'ModuleNotFoundError: No module named 'RNA''. thank you for your help!

Have you tried just running conda install -c bioconda viennarna from inside the PyCharm terminal?

You must make sure the python interpreter that your PyCharm project is using is the one from your conda distribution, not a system python of pycharms own.

I tried to run it from the anaconda terminal and got 'PackagesNotFoundError: The following packages are not available from current channels: -viennarna'. On anconcda's website (https://anaconda.org/bioconda/viennarna) they mention that this package is only available for linux and osx, so I guess this is the reason that it is not working. I'm absolutely sure that i'm using the right python version as my PyCharm's interpreter (i've already installed a lot of packages using pip or conda and used them in pycharm afterwards).

From the github it looks like a C program, so it doesn't make any sense to install it in python. I have only looked through a few of the directories but I don't see any python at all.

It is a C program, but they say on github that "The package includes Perl 5, Python 2, and Python 3 modules that give access to almost all functions of the C library from within the respective scripting languages" but i was not able to do so

Not true, many C (or other language programs) have python bindings to enable their use.

Conda also isn’t purely for python anymore.

1 answer

If anyone else encounters this problem I found a workaround: after downloading and installing the software from https://www.tbi.univie.ac.at/RNA/index.html#pack_windows you will get many EXEs files with the different viennaRNA features. Instead of installing to package you can run these EXEs from your python using: from subprocess import Popen, PIPE p = subprocess.Popen('RNAfold.exe', stdin=PIPE, stdout=PIPE) ans = p.communicate('ATGTTGGGTTCCCCGTGTTGAAAATGTGAAGTAT'.encode())

I'm new to phyton. I would be graceful if you can give the exact code line you used. Something with subprocess ... ?

Just delete "subprocess.", use p = Popen('RNAfold.exe', stdin=PIPE, stdout=PIPE) instead.

Log in to answer this question.