python-binance icon indicating copy to clipboard operation
python-binance copied to clipboard

ModuleNotFoundError: No module named 'binance'

Open 0xN1C04ND3 opened this issue 4 years ago • 7 comments

Trying to access the binance API.

from binance.client import client client = client(api_key, api_secret)

But I get this error :

D:\Users\username\Desktop\pyproject>get_data.py Traceback (most recent call last): File "D:\Users\username\Desktop\pyproject\get_data.py", line 1, in from binance.client import client ModuleNotFoundError: No module named 'binance'

Everything was installed as expected. Using pip install python-binance command

There is a binance directory in ...\site-packages\

System paths for python using import sys sys.path are : ['', 'D:\Users\username\AppData\Local\Programs\Python\Python38\python38.zip', 'D:\Users\username\AppData\Local\Programs\Python\Python38\DLLs', 'D:\Users\username\AppData\Local\Programs\Python\Python38\lib', 'D:\Users\username\AppData\Local\Programs\Python\Python38', 'D:\Users\username\AppData\Local\Programs\Python\Python38\lib\site-packages', 'D:\Users\username\AppData\Local\Programs\Python\Python38\lib\site-packages\win32', 'D:\Users\username\AppData\Local\Programs\Python\Python38\lib\site-packages\win32\lib', 'D:\Users\username\AppData\Local\Programs\Python\Python38\lib\site-packages\Pythonwin']

I have tried everything.

Please help ! Thank you

0xN1C04ND3 avatar Jan 12 '21 11:01 0xN1C04ND3

a possible reason could be, that you install with pip for python2 but you run the script with python3.

just try to install with pip3 or python3 -m pip install python-binance and then run your script again and look if its solved.

oliver-zehentleitner avatar Jan 12 '21 14:01 oliver-zehentleitner

I gave It a chance but no success... I have pip 20.3.3

Thank you for helping @oliver-zehentleitner

0xN1C04ND3 avatar Jan 12 '21 14:01 0xN1C04ND3

I had the exact same issue today, hopefully this will help you too. I realised it was because I had named my file binance.py !!! Why do stupid errors take the longest to unpick.

RustyBadRobot avatar Jan 13 '21 16:01 RustyBadRobot

Same problem here on Ubuntu 18.04LTS and Windows 10. When running pip install python-binance, there appears to be an error when installing Twisted:

src/twisted/test/raiser.c:4:10: fatal error: Python.h: No such file or directory
     #include "Python.h"
              ^~~~~~~~~~
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Everything I have found about this error says to install python3-dev and/or python-dev. It didn't help me but it may help you.

hmellor avatar Jan 18 '21 18:01 hmellor

Same problem here on Ubuntu 18.04LTS and Windows 10. When running pip install python-binance, there appears to be an error when installing Twisted:

src/twisted/test/raiser.c:4:10: fatal error: Python.h: No such file or directory
     #include "Python.h"
              ^~~~~~~~~~
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Everything I have found about this error says to install python3-dev and/or python-dev. It didn't help me but it may help you.

When installing with python3.9 on Ubuntu 20.04.2 LTS I ran into the same error listed here. Steps to resolve were:

sudo apt-get update sudo apt-get upgrade sudo apt install python3.9-dev pip install python-binance

All worked as intended afterwards

uneasyguy avatar Jan 30 '21 13:01 uneasyguy

by calling your file binance.py, and then trying to import from binance.client python is looking in your binance.py file.

If you rename your local file then you won't have an issue.

pypiHat avatar Nov 19 '21 12:11 pypiHat

I had that same problem. I solve it by uninstalling all libraries named "binance" and the installing the one that i need on the console of the program that I use (spyder). I mean, try in your "cmd" to do "pip uninstall binance" and also "pip uninstall python-binance", then enter in the enviroment or lenguague you are using (I recomend to use spyder from anaconda) to code and in the console of that enviroment or lenguague write "pip install python-binance". Problem solved ;). I use spyder as enviroment or lenguage.

JBFerrer avatar Jul 07 '22 11:07 JBFerrer