缺少 numpy 在运行其他外部 Python 脚本时

huangapple go评论75阅读模式
英文:

Missing numpy while running other external python script

问题

我正在尝试从Python脚本中运行一个Python脚本。

我尝试以以下方式运行它:

os.system("python /opt/mycroft/skills/useridentification-skill/speakerIdentificationProgram/scoring.py")

然后我尝试像这样导入文件:

import sys
sys.path.append("/opt/mycroft/skills/useridentification-skill/speakerIdentificationProgram")
from scoring import get_id_result

它们都返回了这个错误:

File "/opt/mycroft/skills/useridentification-skill/__init__.py", line 9, in <module>
    from scoring import get_id_result
  File "/opt/mycroft/skills/useridentification-skill/speakerIdentificationProgram/scoring.py", line 2, in <module>
    import numpy
ImportError: No module named 'numpy'
英文:

I am trying to run a python script from python script.

I tried to run it like this:

os.system(&quot;python /opt/mycroft/skills/useridentification-skill/speakerIdentificationProgram/scoring.py&quot;)

Then I tried to import the file like this:

import sys
sys.path.append(&quot;/opt/mycroft/skills/useridentification-skill/speakerIdentificationProgram&quot;)
from scoring import get_id_result

they both returned this error:

File &quot;/opt/mycroft/skills/useridentification-skill/__init__.py&quot;, line 9, in &lt;module&gt;
    from scoring import get_id_result
  File &quot;/opt/mycroft/skills/useridentification-skill/speakerIdentificationProgram/scoring.py&quot;, line 2, in &lt;module&gt;
    import numpy
ImportError: No module named &#39;numpy&#39;

答案1

得分: 2

只需在您的终端中尝试执行pip install numpy。这将解决错误。

英文:

just try pip install numpy in your terminal. this will remove error

答案2

得分: 1

我认为您在scoring.py中正在使用numpy模块,但您尚未在您的虚拟环境中安装numpy。在激活虚拟环境后使用 "pip install numpy"。

英文:

I think you are using numpy module in scoring.py but you have not installed numpy in your virtual environment.
Use "pip install numpy" after activating your virtualenv.

答案3

得分: 0

我假设您已按照以下方式添加技能,如果是这样的话,它应该会安装NumPy,如果技能确实需要它。

https://mycroft-ai.gitbook.io/docs/mycroft-technologies/mycroft-core/msm

参考 - https://github.com/MycroftAI/documentation/issues/143

否则,您应该使用:

mycroft-pip install numpy

然后您应该使用source来激活Mycroft虚拟环境,然后使用Python命令来运行您的脚本。

英文:

I assume you followed this to add skills, if so it should install numpy if the skill actually required it

https://mycroft-ai.gitbook.io/docs/mycroft-technologies/mycroft-core/msm

Ref - https://github.com/MycroftAI/documentation/issues/143

Otherwise, you should be using

mycroft-pip install numpy

And you should be source to activate the mycroft venv, and then use the Python command to run your script

答案4

得分: -2

使用Panda库进行数据操作和文件访问。
https://www.learnpython.org/en/Pandas_Basics

然后
npm install numpy

英文:

Use Panda libraries for data manipulation and file access.
https://www.learnpython.org/en/Pandas_Basics

then
npm install numpy

huangapple
  • 本文由 发表于 2020年1月3日 15:08:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/59574507.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定