SBRG / ssbio

A Python framework for structural systems biology
http://ssbio.readthedocs.io/en/latest/
MIT License
101 stars 28 forks source link

AttributeError: 'module' object has no attribute 'urlretrieve' #8

Closed erolkavvas closed 7 years ago

erolkavvas commented 7 years ago

I'm getting the following error when running the example notebook "GEM-PRO pipeline - one gene with sequence.ipynb".


AttributeError Traceback (most recent call last)

in () ----> 1 my_gempro.set_representative_structure() /home/user/ssbio/ssbio/pipeline/gempro.pyc in set_representative_structure(self, seq_outdir, struct_outdir, pdb_file_type, engine, always_use_homology, seq_ident_cutoff, allow_missing_on_termini, allow_mutants, allow_deletions, allow_insertions, allow_unresolved, force_rerun) 1109 allow_insertions=allow_insertions, 1110 allow_unresolved=allow_unresolved, -> 1111 force_rerun=force_rerun) 1112 1113 if not repstruct: /home/user/ssbio/ssbio/core/protein.pyc in set_representative_structure(self, seq_outdir, struct_outdir, pdb_file_type, engine, always_use_homology, seq_ident_cutoff, allow_missing_on_termini, allow_mutants, allow_deletions, allow_insertions, allow_unresolved, force_rerun) 591 # This will add all chains to the mapped_chains attribute if there are none 592 try: --> 593 pdb.download_structure_file(outdir=struct_outdir, file_type=pdb_file_type, force_rerun=force_rerun) 594 # Download the mmCIF header file to get additional information 595 if 'cif' not in pdb_file_type: /home/user/ssbio/ssbio/databases/pdb.pyc in download_structure_file(self, outdir, file_type, force_rerun) 44 pdb_file = download_structure(pdb_id=self.id, file_type=file_type, only_header=False, 45 outdir=outdir, ---> 46 force_rerun=force_rerun) 47 log.debug('{}: downloaded {} file'.format(self.id, file_type)) 48 self.load_structure_file(pdb_file, file_type) /home/user/ssbio/ssbio/databases/pdb.pyc in download_structure(pdb_id, file_type, outdir, outfile, only_header, force_rerun) 127 128 if python_version == 2: --> 129 urllib2.urlretrieve(download_link, outfile) 130 html = urllib2.urlopen(download_link).read() 131 with open(outfile, 'wb') as f: AttributeError: 'module' object has no attribute 'urlretrieve'

It occurs at the "my_gempro.set_representative_structure()" line.

erolkavvas commented 7 years ago

I think i resolved the issue by changing "import urllib" to "import urllib as urllib2"

erolkavvas commented 7 years ago

I just noted that at the beginning of my notebook, I have the following code "import urllib2". So the problem could have been specific to my problem.

nmih commented 7 years ago

Fixed it w/ the 'six' python package, thanks Erol.