简体   繁体   English

即使安装了软件包,也无法解析 python 导入模块

[英]Can't resolve python import module even though packages are installed

Im on Ubuntu 20.4.我在 Ubuntu 20.4 上。 When I execute a python script, I get the following error.当我执行 python 脚本时,出现以下错误。 error and sys.path错误和 sys.path

I installed the packages with pip3 and they are located in我用 pip3 安装了这些包,它们位于

/usr/local/lib/python3.8/dist-packages

When I look at the installed packages for python3 and python3.8 interpreter, I see "binance" package installed and recognized.当我查看 python3 和 python3.8 解释器的已安装包时,我看到“binance”包已安装并被识别。 recognized packages认可的包裹

I tried to set PYTHONPATH to point to my project folder, but that didnt help either.我试图将 PYTHONPATH 设置为指向我的项目文件夹,但这也没有帮助。

echo $PYTHONPATH --> /algos_python

Can somebody help me out here?有人可以帮我吗? I can't get my head around the problem.我无法解决这个问题。

Try these:试试这些:

  1. python3 -m pip install python-binance
  2. If you are calling your file binance.py (Or have a file/folder named that in your directory), and then trying to import from binance.client , python will look in your binance.py file instead of the library.如果您正在调用文件binance.py (或者在您的目录中有一个名为该文件的文件/文件夹),然后尝试从binance.client导入,python 将查看您的binance.py文件而不是库。 So try renaming your local file.所以尝试重命名您的本地文件。

You have installed binance from PYPI but you are not using it.您已经从 PYPI 安装了binance ,但您没有使用它。 You are using python-binance and you need to install it.您正在使用python-binance并且需要安装它。 (Using python3 -m pip install python-binance ) and then run your code again. (使用python3 -m pip install python-binance )然后再次运行您的代码。 See this for more info on this.更多这方面的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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