Problem with binance.client

Hello! First of all, I apologize, I'm not very good with English :)) I have a problem wiht binance.client. I tried to run a program with three modules to import - asyncio, smtplib and binance.client. I wrote: "from binance.client import Client"and when run the program I receive message: "from binance.client import Client ModuleNotFoundError: No module named 'binance.client'; 'binance' is not a package". In my computer the same program is running without any problems. What can I do to solve this?

That sounds like you have something in your Python path called "binance" that is colliding with the module. Make sure that you do not have any Python files or directories that are called "binance" (or "") that are not the binance module that you want to import from.

Thank you for response, glenn. Yes, I realy had one folder with "binance" as one of the name words. I renamed the file but situation is the same - the program doesn't run. The files with "binance'' that I have are the ones in the "venv\lib\site-packages" folder. These folders are: "binance", "" and "binance-0.3.dist-info".

Are you sure that you run your code in that virtual environment?

Yes, I think so :)). What do you mean?

The path where your binance package is installed is a virtualenv. Did you activate that virtualenv before you ran your code?

I created virtualenv with bash but I cant install the needed packages for my program. How can I do this? I searched already in internet how to do this and now I am more confused.

See the first few sections here:

Yeah, I've already seen that and follow the steps but the result is the same. Just to notice I use free account and run my program as schedule task.

What is the result?

"from binance.client import Client ModuleNotFoundError: No module named 'binance.client'; 'binance' is not a package"

Then you still have something on your Python path that is named "binance" that is not a Python module.

Maybe. When I search "binance" in my folders the only "binance" files I have are in "pycharm projects" folder in "venv". I have two projects with installed binance packages. Could the problem be there?

I think from what you're saying that you're running the commands that are generating that error in a console. Could you start a new console, then try to run the program, and then post here exactly what commands you entered, and the error messages that you got?

Here it is what I run with bash: 13:35 ~ $ ls README.txt Trading 07:47 ~ $ python --version Python 3.9.5 07:47 ~ $ python3.9
Python 3.9.5 (default, May 27 2021, 19:45:35) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information.

quit() 07:50 ~ $ python3.9 Trading /usr/local/bin/python3.9: can't find 'main' module in '/home/Madmartigan/Trading' 07:55 ~ $ python3.9 Trading/ Traceback (most recent call last): File "/home/Madmartigan/Trading/", line 3, in <module> from binance.client import Client ModuleNotFoundError: No module named 'binance.client'; 'binance' is not a package 07:56 ~ $

Are you sure that the "binance" package that you have installed is actually the module that you are trying to use? Perhaps you have installed something that has a similar name to what you want.

I have installed both 'binance' and 'python-binance' modules. "Client" is a part of python-binance package. The program runs on my PC without any problems.

Have you tried uninstalling the module called "binance"?

Yes, I tried. The result:

11:00 ~ $ python3.9 /home/Madmartigan/Trading/ Traceback (most recent call last): File "/home/Madmartigan/Trading/", line 3, in <module> from binance.client import Client ModuleNotFoundError: No module named 'binance.client'; 'binance' is not a package 11:01 ~ $

What is the result of running this?

python3.9 -c "import binance; print(binance.__file__)"

The result is: /home/Madmartigan/.local/lib/python3.9/site-packages/

So, then you have not uninstalled the binance package in Python 3.9 and your import is trying to import from that.

Very wierd. I uninstalled binance package from the current project.

When you say "current project" do you mean a virtualenv, because the example with the error above does not appear to be in a virtualenv.

I mean the project in pycharm on my PC.

Unless you have some clever code to synchronise your package installs, your PyCharm installation is not going to affect what's on PythonAnywhere.

Ok, but where PyhonAnywhere look for imports? If it looks in virtualenv there is no such file as "binance"...

If you have a virtualenv activated, it will look in there. But the post you made earlier was not running in a virtualenv -- it was picking up a package called binance that you had installed into your account using pip3.9 install --user and then the name of the package.

And if I acitvate virutalenv then the program will start to work? How can I activate virtualenv?

When you activate virtualenv in the console pip relates to packages in that virtualenv so you install and uninstall packages in that vierualenv. Acrtivatio depends on how you created virtualenv. If you used mkvirtualenv you can use workon command to activate. If you want your web app to run in the vrualenv you have to configure it on the "Web" page.

The program is running at last!!! I installed python-binance package in virtualenv and it works! Thank you for support guys! It was very polite and usefull !

Glad to hear you made it work!

It worked but only for a few hours then stoped. If I tried to start from bash it returns:

bash: /home/Madmartigan/Trading/ Permission denied

What is the problem now?

Were you running it in a Python console in the editor before? The general rule is that all our consoles are not designed for long running jobs -- if you need one, you should consider using the Always-on task feature. If you want to run the script in the Bash console, you have to either make it executable and add so called shebang (string starting with "#!" at the beginning of the script that specifies the executable which should be used to run it, in your case that would be the python from a virtual env, I guess) OR to run it with Python like this: python /home/Madmartigan/Trading/ (keep in mind that if you use a venv, you should activate it first, or provide the full path to the Python executable in the venv).

OK, thank you.