ModuleNotFoundError:没有名为“plotly”的模块;但它可以在工作区工作

发布于 2025-01-10 15:59:44 字数 703 浏览 4 评论 0原文

我已阅读与此主题相关的所有帖子,但我找不到适合我的案例的解决方案。

在我的 ubuntu 20.04 中,我已经通过命令进行了安装:

pip3 install plotly

如果我从命令行启动 python3 并且运行:

import plotly.graph_objects as go

它可以完美运行。但是如果我从 python 脚本“test.py”启动相同的命令:

#!/usr/bin/python3
# -*- coding: utf-8 -*-
import cgi
import cgitb
from datetime import date, timedelta
import datetime
import time
import numpy as np
import pandas as pd
import os
import calendar
import matplotlib
matplotlib.use('Agg')
import matplotlib.pylab as plt
import plotly.graph_objects as go

它会返回错误日志:

 ModuleNotFoundError: No module named 'plotly'

任何人都可以帮助我吗?非常感谢

i have read all the posts related to this topic but i could not find the solution for my case.

In my ubuntu 20.04 I have installed plotly through the command:

pip3 install plotly

and if i launch python3 from command line and if i run:

import plotly.graph_objects as go

it works perfectly. But if i launch the same command from python script "test.py":

#!/usr/bin/python3
# -*- coding: utf-8 -*-
import cgi
import cgitb
from datetime import date, timedelta
import datetime
import time
import numpy as np
import pandas as pd
import os
import calendar
import matplotlib
matplotlib.use('Agg')
import matplotlib.pylab as plt
import plotly.graph_objects as go

it returns the error log:

 ModuleNotFoundError: No module named 'plotly'

Anyone can help me? many thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

坠似风落 2025-01-17 15:59:44

好的,我通过以 root 用户身份安装模块解决了这个问题,因为这样 Python 会尝试在根目录中搜索模块的名称,而不是在 usr 目录中,

谢谢大家

Ok, i resolved the issue by installing the module as a root user because in this way Python will try to search for the module’s name in the root directory and not in the usr one

thank you everyone

半夏半凉 2025-01-17 15:59:44

经过一段时间寻找适用于我的案例的答案但没有找到。我通过转到安装Python版本及其包的目录解决了这个问题,对我来说:(C:\Users\nslab\AppData\Local\Programs\Python\Python39\Lib\site-packages)。我删除了所有引用“plotly”的文件,并使用终端中的“pip”再次重新安装了该软件包(plotly)。观察:我使用 VSCode。所以它起作用了

After a while looking for an answer that worked in my case and not found. I solved this problem by going to the directory where the Python version is installed and its package, for me: (C:\Users\nslab\AppData\Local\Programs\Python\Python39\Lib\site-packages). I deleted all files referring to 'plotly' and reinstalled this package (plotly) again with 'pip' from Terminal. Obs.: I use VSCode. So it worked

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文