找不到模块名为 ‘fastapi’ – Ubuntu 环境

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

No Module named 'fastapi' - Ubuntu environment

问题

尽管我在基于Ubuntu的工作站上安装了pip和pip3,但我得到一个奇怪的错误,提示“没有找到'fastapi'模块”。

我已经困惑了两天,因为在另一台装有相同Ubuntu环境的笔记本电脑上,相同的代码可以运行。

卸载并重新安装了fastapi库。

英文:

Though I have pip and pip3 installed fastapi library in my Ubuntu based workstation, I get a weird error saying

> No module named 'fastapi'.

I have been scratching my head since two days ago as the same code works in other laptop with same Ubuntu environment.

找不到模块名为 ‘fastapi’ – Ubuntu 环境

Uninstalled and reinstalled fastapi library

答案1

得分: 1

你没有使用正确的环境来运行你的代码。
要么,1. 在你运行代码的环境中安装fast-api包,要么 2. 切换到已安装包的另一个环境:

对于1:
sudo /bin/python3 -m pip install "fastapi[all]"

在这种情况下,你应该能够使用fast-api包。
注意:你使用的其他包可能也没有安装。

英文:

you're not using the correct environment to run your code.
Either, 1. install the package fast-api in the environment you running the code in or 2. switch to the other one the packages are installed in:

for 1:
sudo /bin/python3 -m pip install "fastapi[all]"

in this case you should be able to use the fast-api package
Note: the other packages you use are probably not installed as well

答案2

得分: 0

  1. 可能您正在使用错误的环境?看起来您正在使用VSCode,所以您可以指定解释器
  2. 尝试运行 pip install --upgrade pip,然后再次运行 pip install fastapi
  3. 尝试使用conda,然后运行 conda install -c conda-forge fastapi
英文:
  1. Maybe you are using the wrong env? It looks like you're using vscode so you can specify the interpeter
  2. Try pip install --upgrade pip and then pip install fastapi again
  3. Try using conda, and do conda install -c conda-forge fastapi

huangapple
  • 本文由 发表于 2023年2月19日 14:43:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/75498440.html
匿名

发表评论

匿名网友

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

确定