# Problem with PyYAML installing DASH

**URL:** <https://community.plotly.com/t/problem-with-pyyaml-installing-dash/25713>\
**Category:** Dash Python\
**Created:** [July 10, 2019, 8:33pm UTC](https://community.plotly.com/t/problem-with-pyyaml-installing-dash/25713 "2019-07-10T20:33:30Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgriffi](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@jgriffi](https://community.plotly.com/u/jgriffi)\
**Post date:** [July 10, 2019, 8:33pm UTC](https://community.plotly.com/t/problem-with-pyyaml-installing-dash/25713/1 "2019-07-10T20:33:30Z")

</div>

Hi All,

I’m trying to pip install dash and I’m getting this error message:

Cannot uninstall ‘PyYAML’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

I’m running python 3.7 with pip 19.0.3. Can anyone help? I need to get this sorted quickly as I’ve got a demo to prepare.

Thanks in advance

---

<div class="post-metadata">

**Author:** ![Damian](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@Damian](https://community.plotly.com/u/Damian)\
**Post date:** [July 10, 2019, 8:38pm UTC](https://community.plotly.com/t/problem-with-pyyaml-installing-dash/25713/2 "2019-07-10T20:38:16Z")

</div>

Can you paste your exact command and full error message.

---

<div class="post-metadata">

**Author:** ![jgriffi](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@jgriffi](https://community.plotly.com/u/jgriffi)\
**Post date:** [July 10, 2019, 9:28pm UTC](https://community.plotly.com/t/problem-with-pyyaml-installing-dash/25713/3 "2019-07-10T21:28:17Z")

</div>

Hi Damian,

Here’s what I did.

**pip install dash**

Collecting dash

Collecting dash-html-components==1.0.0 (from dash)

Requirement already satisfied: Flask\>=1.0.2 in /anaconda3/lib/python3.7/site-packages (from dash) (1.0.2)

Collecting PyYAML\>=5.1.1 (from dash)

Collecting flask-compress (from dash)

Collecting dash-core-components==1.0.0 (from dash)

Collecting dash-renderer==1.0.0 (from dash)

Collecting dash-table==4.0.1 (from dash)

Collecting plotly (from dash)

Using cached [https://files.pythonhosted.org/packages/ff/75/3982bac5076d0ce6d23103c03840fcaec90c533409f9d82c19f54512a38a/plotly-3.10.0-py2.py3-none-any.whl](https://files.pythonhosted.org/packages/ff/75/3982bac5076d0ce6d23103c03840fcaec90c533409f9d82c19f54512a38a/plotly-3.10.0-py2.py3-none-any.whl)

Requirement already satisfied: itsdangerous\>=0.24 in /anaconda3/lib/python3.7/site-packages (from Flask\>=1.0.2-\>dash) (1.1.0)

Requirement already satisfied: Jinja2\>=2.10 in /anaconda3/lib/python3.7/site-packages (from Flask\>=1.0.2-\>dash) (2.10)

Requirement already satisfied: Werkzeug\>=0.14 in /anaconda3/lib/python3.7/site-packages (from Flask\>=1.0.2-\>dash) (0.14.1)

Requirement already satisfied: click\>=5.1 in /anaconda3/lib/python3.7/site-packages (from Flask\>=1.0.2-\>dash) (7.0)

Requirement already satisfied: decorator\>=4.0.6 in /anaconda3/lib/python3.7/site-packages (from plotly-\>dash) (4.4.0)

Collecting retrying\>=1.3.3 (from plotly-\>dash)

Requirement already satisfied: pytz in /anaconda3/lib/python3.7/site-packages (from plotly-\>dash) (2018.9)

Requirement already satisfied: requests in /anaconda3/lib/python3.7/site-packages (from plotly-\>dash) (2.21.0)

Requirement already satisfied: six in /anaconda3/lib/python3.7/site-packages (from plotly-\>dash) (1.12.0)

Requirement already satisfied: nbformat\>=4.2 in /anaconda3/lib/python3.7/site-packages (from plotly-\>dash) (4.4.0)

Requirement already satisfied: MarkupSafe\>=0.23 in /anaconda3/lib/python3.7/site-packages (from Jinja2\>=2.10-\>Flask\>=1.0.2-\>dash) (1.1.1)

Requirement already satisfied: idna\<2.9,\>=2.5 in /anaconda3/lib/python3.7/site-packages (from requests-\>plotly-\>dash) (2.8)

Requirement already satisfied: certifi\>=2017.4.17 in /anaconda3/lib/python3.7/site-packages (from requests-\>plotly-\>dash) (2019.3.9)

Requirement already satisfied: chardet\<3.1.0,\>=3.0.2 in /anaconda3/lib/python3.7/site-packages (from requests-\>plotly-\>dash) (3.0.4)

Requirement already satisfied: urllib3\<1.25,\>=1.21.1 in /anaconda3/lib/python3.7/site-packages (from requests-\>plotly-\>dash) (1.24.1)

Requirement already satisfied: traitlets\>=4.1 in /anaconda3/lib/python3.7/site-packages (from nbformat\>=4.2-\>plotly-\>dash) (4.3.2)

Requirement already satisfied: jsonschema!=2.5.0,\>=2.4 in /anaconda3/lib/python3.7/site-packages (from nbformat\>=4.2-\>plotly-\>dash) (3.0.1)

Requirement already satisfied: jupyter-core in /anaconda3/lib/python3.7/site-packages (from nbformat\>=4.2-\>plotly-\>dash) (4.4.0)

Requirement already satisfied: ipython-genutils in /anaconda3/lib/python3.7/site-packages (from nbformat\>=4.2-\>plotly-\>dash) (0.2.0)

Requirement already satisfied: attrs\>=17.4.0 in /anaconda3/lib/python3.7/site-packages (from jsonschema!=2.5.0,\>=2.4-\>nbformat\>=4.2-\>plotly-\>dash) (19.1.0)

Requirement already satisfied: pyrsistent\>=0.14.0 in /anaconda3/lib/python3.7/site-packages (from jsonschema!=2.5.0,\>=2.4-\>nbformat\>=4.2-\>plotly-\>dash) (0.14.11)

Requirement already satisfied: setuptools in /anaconda3/lib/python3.7/site-packages (from jsonschema!=2.5.0,\>=2.4-\>nbformat\>=4.2-\>plotly-\>dash) (40.8.0)

Installing collected packages: dash-html-components, PyYAML, flask-compress, dash-core-components, dash-renderer, dash-table, retrying, plotly, dash

Found existing installation: PyYAML 5.1

**Cannot uninstall ‘PyYAML’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.**

---

<div class="post-metadata">

**Author:** ![alexcjohnson](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/alexcjohnson/32/614_2.png) [@alexcjohnson](https://community.plotly.com/u/alexcjohnson)\
**Post date:** [July 10, 2019, 9:35pm UTC](https://community.plotly.com/t/problem-with-pyyaml-installing-dash/25713/4 "2019-07-10T21:35:33Z")

</div>

I guess this is implying that `PyYAML` was installed by something other than `pip`? Not sure how to fix it per se, but in order to get you running quickly, can you install dash (and whatever else you need for your demo) in a virtual env?

```auto
python -m venv venv
. venv/bin/activate
pip install dash

```

---

<div class="post-metadata">

**Author:** ![jgriffi](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@jgriffi](https://community.plotly.com/u/jgriffi)\
**Post date:** [July 10, 2019, 9:39pm UTC](https://community.plotly.com/t/problem-with-pyyaml-installing-dash/25713/5 "2019-07-10T21:39:44Z")

</div>

I thought I may have to do that. Thanks.

---

<div class="post-metadata">

**Author:** ![Damian](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@Damian](https://community.plotly.com/u/Damian)\
**Post date:** [July 10, 2019, 9:43pm UTC](https://community.plotly.com/t/problem-with-pyyaml-installing-dash/25713/6 "2019-07-10T21:43:10Z")

</div>

It looks like pyyaml was installed via conda, you should update it via conda:

```
conda update pyyaml 

```

Then try installing Dash via Pip.

---

<div class="post-metadata">

**Author:** ![jgriffi](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@jgriffi](https://community.plotly.com/u/jgriffi)\
**Post date:** [July 10, 2019, 11:24pm UTC](https://community.plotly.com/t/problem-with-pyyaml-installing-dash/25713/7 "2019-07-10T23:24:48Z")

</div>

I tried that, same error. I created a virtual env and installed dash there. But I have a new problem. How do I sort this?

Thanks

 ![26](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/9/95e245fcbb65c53adc9d6ee23412912caeb1ba09.png)

---

<div class="post-metadata">

**Author:** ![jgriffi](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@jgriffi](https://community.plotly.com/u/jgriffi)\
**Post date:** [July 11, 2019, 8:17am UTC](https://community.plotly.com/t/problem-with-pyyaml-installing-dash/25713/8 "2019-07-11T08:17:43Z")

</div>

I created a virtual env and installed dash there. But I have a new problem. How do I sort this?

Thanks

 ![26](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/9/95e245fcbb65c53adc9d6ee23412912caeb1ba09.png)

---

<div class="post-metadata">

**Author:** ![alexcjohnson](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/alexcjohnson/32/614_2.png) [@alexcjohnson](https://community.plotly.com/u/alexcjohnson)\
**Post date:** [July 11, 2019, 10:39am UTC](https://community.plotly.com/t/problem-with-pyyaml-installing-dash/25713/9 "2019-07-11T10:39:10Z")

</div>

`Event` was removed in Dash 0.36 [https://github.com/plotly/dash/blob/master/dash/CHANGELOG.md#0360---2019-01-25](https://github.com/plotly/dash/blob/master/dash/CHANGELOG.md#0360---2019-01-25)

> Use event properties instead, for example the `n_clicks` property instead of the `click` event

As well as `dash.callback_context` to know which input changed [📣 Dash Club - Dispatch #4 - Latest Dash Developments](https://community.plotly.com/t/dash-club-dispatch-4-latest-dash-developments/20480)

---

<div class="post-metadata">

**Author:** ![jgriffi](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@jgriffi](https://community.plotly.com/u/jgriffi)\
**Post date:** [July 11, 2019, 12:18pm UTC](https://community.plotly.com/t/problem-with-pyyaml-installing-dash/25713/10 "2019-07-11T12:18:16Z")

</div>

Thanks for responding so promptly. As I am new to Dash your help has been very much appreciated. Another question about my Event issue. As seen in the code snippet a live graph for twitter sentiment. My question is how do I implement n\_clicks here?

 ![20](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/8/8433475be4709cea2b51a5d294d07e0a3f05c1db.png)

---

<div class="post-metadata">

**Author:** ![alexcjohnson](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/alexcjohnson/32/614_2.png) [@alexcjohnson](https://community.plotly.com/u/alexcjohnson)\
**Post date:** [July 11, 2019, 2:06pm UTC](https://community.plotly.com/t/problem-with-pyyaml-installing-dash/25713/11 "2019-07-11T14:06:56Z")

</div>

Happy to help 🙂  
You can use `Input('graph_update', 'n_interval')` for this

---

<div class="post-metadata">

**Author:** ![jgriffi](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@jgriffi](https://community.plotly.com/u/jgriffi)\
**Post date:** [July 11, 2019, 2:45pm UTC](https://community.plotly.com/t/problem-with-pyyaml-installing-dash/25713/12 "2019-07-11T14:45:34Z")

</div>

> [@alexcjohnson](#):
>
> Input(‘graph\_update’, ‘n\_interval’)

I should have really given the full code. Here it is along with my new error. Hopefully, this is final one.

import dash  
from dash.dependencies import Output, Input  
import dash\_core\_components as dcc  
import dash\_html\_components as html  
import plotly  
import random  
import plotly.graph\_objs as go  
from collections import deque  
import sqlite3  
import pandas as pd

app = dash.Dash( **name** )  
app.layout = html.Div([  
html.H2(‘Live Twitter Sentiment’),  
dcc.Graph(id=‘live-graph’, animate=True),  
dcc.Interval(id=‘graph-update’, interval=1 \* 1000),  
])

@app.callback(Output(‘live-graph’, ‘figure’),  
[Input(‘graph\_update’, ‘n\_interval’)])

def update\_graph\_scatter():  
try:  
conn = sqlite3.connect(‘twitter2.db’)  
c = conn.cursor()  
df = pd.read\_sql(“SELECT \* FROM sentiment WHERE tweet LIKE ‘%wimbledon%’ ORDER BY unix DESC LIMIT 1000”, conn)  
df.sort\_values(‘unix’, inplace=True)  
df[‘sentiment\_smoothed’] = df[‘sentiment’].rolling(int(len(df)/5)).mean()  
df.dropna(inplace=True)

```
    X = df.unix.values[-100:]
    Y = df.sentiment_smoothed.values[-100:]
    
    data_1 = plotly.graph_objs.Scatter(x = X,
                                       y = Y,
                                       name = 'Scatter',
                                       mode = 'line+markers')
    
    return {'data': [data_1], 'layout': go.Layout(xaxis = dict(range = [min(X), max(X)]),
                                                 yaxis = dict(range = [min(Y), max(Y)]),)}

except Exception as e:
    with open('errors.txt', 'a') as f:
        f.write(str(e))
        f.write('\n')

```

if **name** == ‘ **main** ’:  
app.run\_server(debug=False)

 ![15](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/9/9975684814a03cea71c14b0053ebc35c57edf4d6.png)

---

<div class="post-metadata">

**Author:** ![alexcjohnson](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/alexcjohnson/32/614_2.png) [@alexcjohnson](https://community.plotly.com/u/alexcjohnson)\
**Post date:** [July 12, 2019, 1:23pm UTC](https://community.plotly.com/t/problem-with-pyyaml-installing-dash/25713/13 "2019-07-12T13:23:32Z")

</div>

ugh we really need to fix that bug [https://github.com/plotly/dash/issues/791](https://github.com/plotly/dash/issues/791)

We’ve detected an error in the callback definition but this bug prevents us from telling you what it is!

I see two issues here:

- be careful about \_ and - in `graph-update` vs `graph_update` (I think this is the one throwing the broken error)
- every input (or state but you don’t have state) needs a corresponding arg in your callback, even if you aren’t going to use it. So `def update_graph_scatter(n):`

---

<div class="post-metadata">

**Author:** ![jgriffi](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@jgriffi](https://community.plotly.com/u/jgriffi)\
**Post date:** [July 15, 2019, 2:02pm UTC](https://community.plotly.com/t/problem-with-pyyaml-installing-dash/25713/14 "2019-07-15T14:02:57Z")

</div>

Yes I do have def update\_graph\_scatter(n): after the callback or am I missing something else.

app = dash.Dash( **name** )  
app.layout = html.Div([  
html.H2(‘Live Twitter Sentiment’),  
dcc.Graph(id=‘live-graph’, animate=True),  
dcc.Interval(id=‘graph-update’, interval=1 \* 1000),  
])

@app.callback(Output(‘live-graph’, ‘figure’),  
[Input(‘graph-update’, ‘interval’)])

def update\_graph\_scatter():  
try:  
conn = sqlite3.connect(‘twitter2.db’)  
c = conn.cursor()  
df = pd.read\_sql(“SELECT \* FROM sentiment WHERE tweet LIKE ‘%wimbledon%’ ORDER BY unix DESC LIMIT 1000”, conn)  
df.sort\_values(‘unix’, inplace=True)  
df[‘sentiment\_smoothed’] = df[‘sentiment’].rolling(int(len(df)/5)).mean()  
df.dropna(inplace=True)

```
    X = df.unix.values[-100:]
    Y = df.sentiment_smoothed.values[-100:]
    
    data_1 = plotly.graph_objs.Scatter(x = X,
                                       y = Y,
                                       name = 'Scatter',
                                       mode = 'line+markers')
    
    return {'data': [data_1], 'layout': go.Layout(xaxis = dict(range = [min(X), max(X)]),
                                                 yaxis = dict(range = [min(Y), max(Y)]),)}

except Exception as e:
    with open('errors.txt', 'a') as f:
        f.write(str(e))
        f.write('\n')

```

if **name** == ‘ **main** ’:  
app.run\_server(debug=False)

---

<div class="post-metadata">

**Author:** ![jgriffi](https://avatars.discourse-cdn.com/v4/letter/j/e19b73/32.png) [@jgriffi](https://community.plotly.com/u/jgriffi)\
**Post date:** [July 15, 2019, 2:03pm UTC](https://community.plotly.com/t/problem-with-pyyaml-installing-dash/25713/15 "2019-07-15T14:03:57Z")

</div>

I apologise for the formatting.

---

<div class="post-metadata">

**Author:** ![alexcjohnson](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/alexcjohnson/32/614_2.png) [@alexcjohnson](https://community.plotly.com/u/alexcjohnson)\
**Post date:** [July 15, 2019, 8:05pm UTC](https://community.plotly.com/t/problem-with-pyyaml-installing-dash/25713/16 "2019-07-15T20:05:53Z")

</div>

@jgriffi try upgrading to dash v1.0.2 [📣 Dash 1.0.2 released](https://community.plotly.com/t/dash-1-0-2-released/25918) - it should fix the “‘Div’ object has no attribute ‘keys’” problem and give you a more helpful error message about what needs fixing in the callback.

---

<div class="post-metadata">

**Author:** ![David22](https://avatars.discourse-cdn.com/v4/letter/d/439d5e/32.png) [@David22](https://community.plotly.com/u/David22)\
**Post date:** [August 7, 2019, 10:29pm UTC](https://community.plotly.com/t/problem-with-pyyaml-installing-dash/25713/17 "2019-08-07T22:29:24Z")

</div>

I have the same issue. Stuck with dash 0.43,  
pip install dash==1.1.1 results in:

Installing collected packages: PyYAML, dash-core-components, dash-html-components, dash-renderer, dash-table, dash  
Found existing installation: PyYAML 3.13  
Cannot uninstall ‘PyYAML’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

---

<div class="post-metadata">

**Author:** ![David22](https://avatars.discourse-cdn.com/v4/letter/d/439d5e/32.png) [@David22](https://community.plotly.com/u/David22)\
**Post date:** [August 7, 2019, 10:46pm UTC](https://community.plotly.com/t/problem-with-pyyaml-installing-dash/25713/18 "2019-08-07T22:46:39Z")

</div>

Error message was:

Cannot uninstall ‘PyYAML’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

I fixed executing this in the conda prompt:  
pip install --ignore-installed PyYAML==5.1.2

It installed PyYAML 5.1.2

And after that pip install dash==1.1.1 worked fine 🙂
