cannot import name xxx from pyecharts

cannot import name ‘…’ from pyecharts
问题纲要 :
1 版本问题
2.anaconda问题
3 pip镜像问题
详述:

在制作疫情热力图时,import报错:

cannot import name Map from pyecharts
cannot import name options from pyecharts

首先,我们确定我们引用方法是否正确,确定是那个版本的pyecharts为此种的引用方式,我的是这样:

from pyecharts import options as opts
from pyecharts.charts import Map

我从网上找到这种引用方法是pycharts 1.7版本的方法,所以确定下版本号,重新下载了pyecharts(卸载pyecharts为pip uninstall pyecharts)。

pip install pyecharts==1.7

但是还是提示cannot import …,我看下载完的提示中pip把文件下载到了anaconda的目录下,猜测有可能为anaconda问题。
2.删除anaconda的配置
删除的第一步:Files–>settings–>project interpreter的路径改变为python的。
在这里插入图片描述第二步:删除配置的环境变量。
在这里插入图片描述
完成,在删除完成anaconda后,不知道其他同学们会出现这样的问题嘛,我用pip下载时告诉我pip不行了,如下:

Fatal error in launcher: Unable to create process using

此时用:

python -m pip install --upgrade pip

更新解决。
最后一步:在解决问题期间,上网搜集的资料提及pip下载镜像问题,在出现cannot import…之前,我为了解决pip的下载缓慢问题,曾经将自己pip的下载镜像更改为清华大学的镜像,随后为了排除一切有可能存在问题的环节,我把镜像改为了原先的pip镜像(我将pip.ini改为pip.txt,这样pip就找不到这个文件,镜像就恢复pip了)。
在这里插入图片描述最后,我重新 win+R,cmd,

pip install pyecharts==1.7

提示下载到了,python的文件夹,而不是anaconda的文件夹下。
如果提示you have already install pyecharts,安全起见可以先卸载,在安装。
卸载:

pip uninstall pyecharts

至此,解决了can not import xxx from pyecharts 的问题。
(一点浅薄的经验,有可能误打误撞解决了,欢迎指正,交流经验)。

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
boston_housing module: Boston housing price regression dataset. cifar10 module: CIFAR10 small images classification dataset. cifar100 module: CIFAR100 small images classification dataset. fashion_mnist module: Fashion-MNIST dataset. imdb module: IMDB sentiment classification dataset. mnist module: MNIST handwritten digits dataset. reuters module: Reuters topic classification dataset. import tensorflow as tf from tensorflow import keras fashion_mnist = keras.datasets.fashion_mnist (x_train, y_train), (x_test, y_test) = fashion_mnist.load_data() mnist = keras.datasets.mnist (x_train, y_train), (x_test, y_test) = mnist.load_data() cifar100 = keras.datasets.cifar100 (x_train, y_train), (x_test, y_test) = cifar100.load_data() cifar10 = keras.datasets.cifar10 (x_train, y_train), (x_test, y_test) = cifar10.load_data() imdb = keras.datasets.imdb (x_train, y_train), (x_test, y_test) = imdb.load_data() # word_index is a dictionary mapping words to an integer index word_index = imdb.get_word_index() # We reverse it, mapping integer indices to words reverse_word_index = dict([(value, key) for (key, value) in word_index.items()]) # We decode the review; note that our indices were offset by 3 # because 0, 1 and 2 are reserved indices for "padding", "start of sequence", and "unknown". decoded_review = ' '.join([reverse_word_index.get(i - 3, '?') for i in x_train[0]]) print(decoded_review) boston_housing = keras.datasets.boston_housing (x_train, y_train), (x_test, y_test) = boston_housing.load_data() reuters= keras.datasets.reuters (x_train, y_train), (x_test, y_test) = reuters.load_data() tf.keras.datasets.reuters.get_word_index( path='reuters_word_index.json' )

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值