1

I'm trying to install Python 2.7.5 and the latest version of Biopython (as well as the prerequisite NumPy) on Windows 8 x64.

I've tried running the installer files for all of these programs and although every time the install seems to go perfectly, when I test to see if Biopython is installed (as instructed by the biopython wiki) I get an error:

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

I have tried using both the x64 and x32 installers for all three programs, and I even tried using WinPython, which comes with NumPy preinstalled and has a package manager which I installed Biopython with. However, it had the same result.

Can anyone help? I have searched and found people having similar errors, although typically they aren't using windows at the time and so I've not had any luck using their remedies.

Arthis
  • 77
  • 1
  • 1
  • 7

5 Answers5

4

The name of the Biopython package is Bio, not bio (see the FAQ, which instructs you to check your version like so):

>>> import Bio
>>> print Bio.__version__

If the "import Bio" line fails, Biopython is not installed.

David Cain
  • 16,484
  • 14
  • 65
  • 75
0

I don't know much about python on windows, but you can try to give the full path of the library using the method described here. I'll paste that user's code so the answer can be complete:

import imp
foo = imp.load_source('module.name', 'C:\Python27\Lib')
foo.MyClass()

On windows, the default path should be something like:

C:\Python27\Lib 

although if it was, you wouldn't have this issue (also not sure about the backslashes)...

Backup solution (from same previous link)...

import sys
# the mock-0.3.1 dir contains testcase.py, testutils.py & mock.py
sys.path.append('/foo/bar/mock-0.3.1')
Community
  • 1
  • 1
philshem
  • 24,761
  • 8
  • 61
  • 127
0

If @David Cain's suggestion of using "Import B" (capital B) still does not work, then your scenario is similar to issues I had in the past when using Windows.

My solution was simple. After installing Biopython I noticed it was located in "C:\Python27\Lib\site-packages".

Solution:

I then copied a directory called "Bio" from "site-packages" and pasted into "C:\Python27\Lib". Voilla! Everything has been working since.

hello_there_andy
  • 2,039
  • 2
  • 21
  • 51
0

I use Anaconda and I had this problem too. I realised that I was trying the import Bio within Anaconda2 directory and I got the same error, but if I try the import Bio out of Anaconda2 directory, it works well.

OneOfAKind_12
  • 446
  • 5
  • 8
0

I had the same problem, but I could import it in PyCharm after package installation, and not inside of Jupyter (Anaconda).

Enayat
  • 3,904
  • 1
  • 33
  • 47