简体   繁体   中英

Already installed plotly but still can't import

I am trying to use plotly within Jupyter Notebook and have followed every step listed in the Getting Started with Plotly for Python here . I created a free account with plotly but when I try to import plotly and set my credentials in jupyter using my username and API, I continually see: ModuleNotFoundError: No module named 'plotly'.

Right on plotly's website it says to update my config file after regenerating my API key. However, I do not have a .plotly folder anywhere on my computer and therefore cannot find the .plotly/.config file to update the key. I'm on a work computer and have searched both my network drives and C: drive for the .plotly folder but I don't get any results.

I can see that plotly is installed: 命令行输出为pip install plotly

I've seen someone mention that maybe I've installed plotly where my python environment can't see it. Here is the pip show plotly output: pip show plotly . How can I check where I'm running python from?

I've also seen someone suggest checking where python is searching for modules using import sys. Here is that output below. The very first filepath lists the plotly folder, which makes me think my issue is a configuration/API one.

import sys / sys.path

I also tried importing plotly using a specific file path and setting my credentials but get a different error. It says I cannot import 'exceptions' but I have an exceptions.py file in my plotly folder: 用filepath导入

I am a Python novice and also not very familiar with command line. Can anyone point me in the right direction for trying to locate the .config plotly file if searching my computer for it turns up nothing?

There are some confusing things for the first sight: I see you may use Anaconda or you installed it previously. But you installed plotly in pure Python using pip . If you have Anaconda installed, then I suggest you to use it. Start anaconda-navigator and install plotly inside of it . Then start your code or Jupyter notebook inside of the same anaconda environment .

For Example: If you run jupyter from anaconda , your code will not find plotly if you installed it in some pure python environment or some other anaconda environment.

UPDATE: If you have the problem you mentioned below, without any knowledge regarding your system, I think the wisest action can be uninstall Anaconda and installing it again. There may be some problem around Anaconda and it should solve it.

Ok, having tried the steps:

  • install plotly via pip
  • run the two-line python program in the Installation guide

I seem to end up with a credentials file - it's the two-liner that creates this.

So check that you can import from the command shell python. If you can, then it's more likely it's a PYTHONPATH issue.

C:\Users\xxx>python
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import  plotly
>>> plotly.tools.set_credentials_file(username='DemoAccount', api_key='lr1c37zw81')
>>> quit()

C:\Users\xxx>dir .plotly
 Volume in drive C is OSDISK
 Volume Serial Number is DCCD-845E

 Directory of C:\Users\xxx\.plotly

09/11/2018  09:25    <DIR>          .
09/11/2018  09:25    <DIR>          ..
09/11/2018  09:25               302 .config
09/11/2018  09:25               142 .credentials
               2 File(s)            444 bytes
               2 Dir(s)  111,849,033,728 bytes free

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM