hupili / python-for-data-and-media-communication-gitbook

An open source book on Python tailed for communication students with zero background
115 stars 62 forks source link

cannot import Bar from pyecharts #166

Open MindyZHAOMinzhu opened 5 years ago

MindyZHAOMinzhu commented 5 years ago

My environment

My question

  1. I cannot import Bar from pyecharts.
屏幕快照 2019-08-03 下午3 18 28
  1. 屏幕快照 2019-08-03 下午3 34 11

    The link here is not work.

The minimum code (snippet) to reproduce the issue

from pyecharts import Bar

Describe the efforts you have spent on this issue

I find the problem is normal. I Google it and find there are many people who face the same problems as mine. I have tried some ways of them to solve the problem but it dod not work.

Some similar solution: https://github.com/pyecharts/pyecharts/issues/750 https://github.com/pyecharts/pyecharts/issues/1

MindyZHAOMinzhu commented 5 years ago

I tried another solution:

from pyecharts.charts import bar

It seems it works, but I am not sure if it is the proper way to solve the problem.

MindyZHAOMinzhu commented 5 years ago

I find a useful Github website which is detailed, but I tried the steps and it did not work. https://github.com/pyecharts/pyecharts

屏幕快照 2019-08-03 下午4 17 27
hupili commented 5 years ago

@ConnorLi96 can you help to also test this. It seems two possible causes to me:

  1. @MindyZHAOMinzhu is using Anaconda so the pip installation may redirect to wrong location. It is suggested to use virtual env to repeat all experiments in the open book
  2. May be Python version or package version break the demo code. -- in this case, we need a more sustainable solution: re-run all the codes with proper package versions, once we solve the issue, let's pip freeze the deps into a requirements.txt so future readers will have less pain. We can also consider to use Pipfile which represents the latest practice in managing deps.

We can use Pipfile to create a turn-key solution, giving the same experience like using Anaconda.

ConnorLi96 commented 5 years ago

I also have tried this module and face same problem in the previous weeks, and then I change to use matplotlib to finish work quickly, rather than focus on solving it. So I guess you can implement your visualization need at first, and then research it when you have leisure @MindyZHAOMinzhu

hupili commented 5 years ago

I see. Thanks for the info. It is good to have an issue even if we encounter problems. So we can fix later. It looks more like version unmatching problem. @ConnorLi96 can you help to see if installing previous version of pyecharts work? i.e. pip3 install pyecharts==x.x.x.

ConnorLi96 commented 5 years ago

v1.0.0 can import Bar.

@MindyZHAOMinzhu

MindyZHAOMinzhu commented 5 years ago

Thank you all a lot!! It works now when I use !pip3 install pyecharts==v1.0.0. It seems there are two editions, and the other edition did not work. I also think there are some problems with my path, when I tried !pip3 install pyecharts==v1.0.0 at first, it did not work, too. I delect all files and tried the steps which written on the pyecharts tutorial, then I found it worked.

My path is as followed,although I am not sure about the meaning😭

屏幕快照 2019-08-06 下午4 14 07
ConnorLi96 commented 5 years ago

you can google sys.path to understand the paths one by one. Actually, the step 1 is not compulsory, just ensure pip command is running on the python you use, and make env clear.

hupili commented 5 years ago

@MindyZHAOMinzhu can you help to revise the corresponding section, so future readers would use v1.0.0 by default?

(later we can revise the whole chapter in order to accommodate later versions of pyecharts; for the moment, fixing version number is the quickest solution).

MindyZHAOMinzhu commented 5 years ago

@MindyZHAOMinzhu can you help to revise the corresponding section, so future readers would use v1.0.0 by default?

(later we can revise the whole chapter in order to accommodate later versions of pyecharts; for the moment, fixing version number is the quickest solution).

OK, I will pull the request.