Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying example scripts #3

Closed
ghost opened this issue May 27, 2017 · 11 comments
Closed

Error when trying example scripts #3

ghost opened this issue May 27, 2017 · 11 comments

Comments

@ghost
Copy link

ghost commented May 27, 2017

I am running python 2.7 on macOS. When I want to try the example script, i.e. from_genbank.py, I get the following error:

Traceback (most recent call last): File "with_plot.py", line 11, in <module> ax, levels = graphic_record.plot() File "/Library/Python/2.7/site-packages/dna_features_viewer/dna_features_viewer.py", line 234, in plot box_linewidth=box_linewidth, box_color=box_color File "/Library/Python/2.7/site-packages/dna_features_viewer/dna_features_viewer.py", line 207, in annotate_feature x1, y1, x2, y2 = get_text_box(text, margin=margin) File "/Library/Python/2.7/site-packages/dna_features_viewer/utils.py", line 39, in get_text_box renderer = text.axes.figure.canvas.get_renderer() AttributeError: 'FigureCanvasMac' object has no attribute 'get_renderer' Tobiass-Air:examples Tobias$ python from_genbank.py Traceback (most recent call last): File "from_genbank.py", line 3, in <module> graphic_record = BiopythonTranslator().translate_record("example_sequence.gb") File "/Library/Python/2.7/site-packages/dna_features_viewer/dna_features_viewer.py", line 468, in translate_record return grecord_class(sequence_length=len(record.seq), features=[ AttributeError: 'str' object has no attribute 'seq'

The other example scripts do not work either.

@Zulko
Copy link
Member

Zulko commented May 27, 2017

Weird, they work fine on my machine (and in the test suite). What command/code exactly are you running ? And what version of DnaFeatureViewer ? Did you install from pip or github ? (although both should work)

@ghost
Copy link
Author

ghost commented May 28, 2017

When I run python tests/test_basics.py, there is no error, but also no output.
when I run python examples/from_genbank.py, I get the error posted above.

@Zulko
Copy link
Member

Zulko commented May 28, 2017

For the tests, it is normal that there is mno output.
For the examples, that may be because you need to be in the "examples" to run them.

cd examples
python from_genbank.py

@ghost
Copy link
Author

ghost commented May 28, 2017

I still get the same error

@Zulko
Copy link
Member

Zulko commented May 28, 2017

After a second look at your error I get the problem, it seems to be a Matplotlib/Mac issue, the Matplotlib canvas should have a "get_renderer" attribute that your graphic backend (called "FigureCanvasMac") doesn't have. What version of matplotlib do you have ?

python -c "import matplotlib; print matplotlib.__version__"

@ghost
Copy link
Author

ghost commented May 28, 2017

1.3.1

@Zulko
Copy link
Member

Zulko commented May 28, 2017

That version if from 4 years ago, we may have something there. Can you try upgrading it ? This should install matplotlib 2.x (which as far as i know is retro-compatible so you shouldn't have trouble with other projects):

sudo pip install --upgrade matplotlib

@ghost
Copy link
Author

ghost commented May 28, 2017

upgrading matplotlib helped running by_hand.py and with_plot.py, but from_genbank.py still produces following error:

Traceback (most recent call last):
  File "from_genbank.py", line 3, in <module>
    graphic_record = BiopythonTranslator().translate_record("example_sequence.gb")
  File "/Library/Python/2.7/site-packages/dna_features_viewer/dna_features_viewer.py", line 468, in translate_record
    return grecord_class(sequence_length=len(record.seq), features=[
AttributeError: 'str' object has no attribute 'seq'
Tobiass-Air:examples Tobias$ python from_genbank.py 
Traceback (most recent call last):
  File "from_genbank.py", line 3, in <module>
    graphic_record = BiopythonTranslator().translate_record("example_sequence.gb")
  File "/Library/Python/2.7/site-packages/dna_features_viewer/dna_features_viewer.py", line 468, in translate_record
    return grecord_class(sequence_length=len(record.seq), features=[
AttributeError: 'str' object has no attribute 'seq'`

and running plot_with_bokeh.py that on:

Traceback (most recent call last):
  File "from_genbank.py", line 3, in <module>
    graphic_record = BiopythonTranslator().translate_record("example_sequence.gb")
  File "/Library/Python/2.7/site-packages/dna_features_viewer/dna_features_viewer.py", line 468, in translate_record
    return grecord_class(sequence_length=len(record.seq), features=[
AttributeError: 'str' object has no attribute 'seq'
Tobiass-Air:examples Tobias$ python plot_with_bokeh.py 
Traceback (most recent call last):
  File "plot_with_bokeh.py", line 8, in <module>
    record = BiopythonTranslator().translate_record(record="example_sequence.gb")
  File "/Library/Python/2.7/site-packages/dna_features_viewer/dna_features_viewer.py", line 468, in translate_record
    return grecord_class(sequence_length=len(record.seq), features=[
AttributeError: 'str' object has no attribute 'seq'`

@Zulko
Copy link
Member

Zulko commented May 29, 2017

Definitely weird. I just pushed the Github master on PyPI, can you try to upgrade you DnaFeaturesViewer to the latest version, just to be sure ?

sudo pip install --upgrade dna_features_viewer

@ghost
Copy link
Author

ghost commented May 29, 2017

it gets even weirder: after updating DnaFeaturesViewer (although the latest version was installed), all the scripts are working. Maybe has to do with first updating Matplotlib and then DnaFeaturesViewer (?)
anyway everything works now. thanks again for your help!

@ghost ghost closed this as completed May 29, 2017
@Zulko
Copy link
Member

Zulko commented May 29, 2017

What this means is that the latest changes and fixes on Github had not been pushed on PyPI, so that was an actual bug. Thanks for the report !

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant