pip - 给出无效语法错误的基本 mlxtend 示例
问题描述
我在 Ubuntu 16.04 上使用 Python 3.5.2。
我已经安装了 sklearn 使用..
sudo apt install python-sklearn
和 mlxtend 使用...
sudo pip3 install mlxtend
我正在尝试运行在 Internet 上找到的基本 Iris 示例,但是当我尝试plot_decision_regions
从以下位置导入时出现错误mlxtend.plotting
:
from mlxtend.plotting import plot_decision_regions
Traceback (most recent call last):
File "scripts/machine.learning.py", line 6, in <module>
from mlxtend.plotting import plot_decision_regions
File "/usr/local/lib/python3.5/dist-packages/mlxtend/plotting/__init__.py", line 15, in <module>
from .heatmap import heatmap
File "/usr/local/lib/python3.5/dist-packages/mlxtend/plotting/heatmap.py", line 74
raise AssertionError(f'len(row_names) (got {len(row_names)})'
^
SyntaxError: invalid syntax
解决方案
我有同样的错误,只是升级到 python3.7 真正的错误是
python 3.5 不支持 f 前缀
使用 conda 升级
conda install -c anaconda python=3.7
然后更新所有依赖
conda update --all
推荐阅读
- javascript - 异步/等待示例不起作用。我究竟做错了什么
- sql - COUNT() 函数不适用于 oracle 中的 ID?检查了网站上的所有主题,没有人适合我
- android - 片段的状态没有被保留
- python - Python:有没有办法找到并删除字符串中第一次和最后一次出现的字符?
- android - 我的数据库有问题:“递归调用getDatabase”
- kubernetes - 在 EKS (Kubernetes) 和 ELB 中使用 gunicorn 和 django 实现高延迟
- bash - '4.5:语法错误:算术运算符无效(错误标记为“.5”)' - 但代码似乎仍然有效。为什么?
- reactjs - 在 Redux 中更新深度嵌套的状态
- kubernetes-helm - Minikube 上的 Helm:更新本地镜像
- r - 为 5 个不同变量的所有可能组合创建平均值