Syntax error while importing the module on Ubuntu 16.04 - python

After a first phase of testing among different Binance API alternative implementations i decided to try the most diffused one: python-binance.
I'm using Python 3.5 on Ubuntu 16.04.
I installed the module with the following command
pip3 install python-binance
Everything was fine so i decided to run my first test script:
import time
import os
from binance.client import Client
api_key = 'my_binance_api'
api_secret = 'my_binance_secret'
client = Client(my_api_key, my_binance_secret )
Unfortunatly i got the following error:
Traceback (most recent call last):
File "prova.py", line 1, in <module>
from binance.client import Client
File "/myhome/.local/lib/python3.5/site-packages/binance/__init__.py", line 9, in <module>
from binance.client import Client, AsyncClient # noqa
File "/myhome/.local/lib/python3.5/site-packages/binance/client.py", line 41
REQUEST_TIMEOUT: float = 10
^
SyntaxError: invalid syntax
Any idea on how to fix this? Thx

As suggested by #OneCricketeer above, i installed a new version of python (3.8) and then, after forcing the reinstall of python-binance via a new version of PIP (unfortunalty mine gets broken) Binance package start working.
I'm gonna list the procedure (including PIP tweaks) just in case someone else out there wanted to avoid useless and unhealty headaches:
pip install python3.x
pip sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1 #update the manager
sudo update-alternatives --config python (chose the latest version)
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo apt-get install python3.8-distutils
python get-pip.py
Use always
python -m pip
to manage the modules
Thanks

Related

how to install cpp man page on debian 10?

from here: https://stackoverflow.com/questaions/34507045/how-to-install-man-pages-for-c11 there is mentioned,
cppman is no longer supported under Ubuntu/apt
and therefor no libstdc++6-<version>-doc could be install via apt anymore.
and the only way to install the man page is via pip3. So I have tried to install
sudo apt-get install python-pip and sudo apt-get install python3-pip. Now, having python3, I can install it via pip3:
pip3 install cppman, everything seems correct, before I tried to cache the man pages: cppman -c, which giver error:
Traceback (most recent call last):
File "/usr/local/bin/cppman", line 40, in <module>
from cppman.main import Cppman
File "/usr/local/lib/python2.7/dist-packages/cppman/main.py", line 26, in <module>
import html
ImportError: No module named html
As could be seen, it uses Python2.7 instead of Python3, that is strange.
From github, I have found similar problem here: https://github.com/aitjcize/cppman/issues/80, where they suggest to do
pip uninstall mancpp
pip3 install mancpp
Which I did, but when installing mancpp again from pip3, then another server error:
Collecting mancpp
Could not install packages due to an EnvironmentError: 404 Client Error: Not Found for url: https://pypi.org/simple/mancpp/
So what now? If you read till here, than you can see there are many errors, but cannot find solution anywhere in stack sites. I only want to have cpp manuals for searching for functions and classes (like std) and mainly for glibc++. As I could do simply with c functions. Why is it so hard? Anyway, how to install the mancpp via pip3?
uname -a:
Linux 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64 GNU/Linux
The script uses #!/usr/bin/env python shebang and on your system python is most probably 2.7. Just edit the script:
sudo vim /usr/local/bin/cppman
Append 3 at the end: #!/usr/bin/env python3 and try again.

No module named api_core.protobuf_helpers. python2.7 and googlecloud

I am trying the following example to test the translation with language auto detection.
It works fine with python3.
But when trying with python2.7 it fails with the following message:
python2.7 example.py multi-language
Traceback (most recent call last):
File "google_example.py", line 295, in <module>
transcribe_file_with_multilanguage()
File "google_example.py", line 214, in transcribe_file_with_multilanguage
from google.cloud import speech_v1p1beta1 as speech
File "/usr/local/lib/python2.7/dist-packages/google/cloud/speech_v1p1beta1/__init__.py", line 17, in <module>
from google.cloud.speech_v1p1beta1 import types
File "/usr/local/lib/python2.7/dist-packages/google/cloud/speech_v1p1beta1/types.py", line 20, in <module>
from google.api_core.protobuf_helpers import get_messages
ImportError: No module named api_core.protobuf_helpers
Output of pip2 freeze | grep google:
google==2.0.2
google-api-core==1.8.0
google-auth==1.6.3
google-cloud-core==0.29.1
google-cloud-speech==0.36.3
googleapis-common-protos==1.6.0b9
You are getting a conflict between package names. As you have the google package installed your environment is trying to fetch the api_core.protobuf_helpers module from it instead of from google-api-core.
To overcome this issue, take the approach of this answer. Uninstall the google package and reinstall it with a different name.
Also note that you are using a beta pre-release of the googleapis-common-protos python. library. If you want to use the current stable version run:
pip2 uninstall googleapis-common-protos
pip2 install googleapis-common-protos==1.5.8
Thanks everyone! I followed the recommendation and uninstalled all the google python modules. I reinstalled them again in the following order.
The order I followed is:
sudo pip2 install google
sudo pip2 install google-api-core
sudo pip2 install google-auth
sudo pip2 install google-cloud-core
sudo pip2 install google-cloud-speech
sudo pip2 install googleapis-common-protos
Now it works:
{
python2.7 interpreter.py multi-language
Waiting for operation to complete...
--------------------
First alternative of result 0: transcript: "hello how are you"
confidence: 0.984296917915
}

Curl is configured to use SSL, but we have not been able to determine which SSL backend it is using

When I perform pip install thumbor I get the following error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/t9/***********************/T/pip-install-knrabyuy/pycurl/setup.py", line 913, in <module>
ext = get_extension(sys.argv, split_extension_source=split_extension_source)
File "/private/var/folders/t9/***********************/T/pip-install-knrabyuy/pycurl/setup.py", line 582, in get_extension
ext_config = ExtensionConfiguration(argv)
File "/private/var/folders/t9/***********************/T/pip-install-knrabyuy/pycurl/setup.py", line 99, in __init__
self.configure()
File "/private/var/folders/t9/***********************/T/pip-install-knrabyuy/pycurl/setup.py", line 316, in configure_unix
specify the SSL backend manually.''')
__main__.ConfigurationError: Curl is configured to use SSL, but we have not been able to determine which SSL backend it is using. Please see PycURL documentation for how to specify the SSL backend manually.
I've tried brew install curl (which was successfull) however I get the same error when I perform pip install thumbor.
Any idea why?
It seems like it's pycurl install error.
When installing on centos try this:
export PYCURL_SSL_LIBRARY=openssl
If you install on macos try this one:
export PYCURL_SSL_LIBRARY=openssl
export LDFLAGS=-L/usr/local/opt/openssl/lib
export CPPFLAGS=-I/usr/local/opt/openssl/include
then run pip install pycurl
I was receiving this error when deploying to Beanstalk since I need pycurl for Celery. While in many discussions people recommend different ssl options, my solution was not to use any of these options. Python config file for deploying looks as follows:
packages:
yum:
git: []
postgresql93-devel: []
libcurl-devel: []
libjpeg-turbo-devel: []
commands:
01_download_pip3:
command: 'curl -O https://bootstrap.pypa.io/get-pip.py'
02_install_pip3:
command: 'python3 get-pip.py'
03_pycurl_uninstall:
command: '/usr/bin/yes | sudo /opt/python/run/venv/bin/pip3 uninstall pycurl'
04_pycurl_reinstall:
command: 'sudo /opt/python/run/venv/bin/pip3 install pycurl'
I did not set any environment variables within the software configuration of Beanstalk.
On MacOS Mojave this worked for me:
export PYCURL_SSL_LIBRARY=openssl
export LDFLAGS=-L/usr/local/opt/openssl/lib;export CPPFLAGS=-I/usr/local/opt/openssl/include;pip3 install pycurl --compile --no-cache-dir
I couldn't get past this error with Python 3.6 from Software Collections, so I installed Python 3.5 from the same repository.
Then I installed Pycurl with:
sudo yum install sclo-python35-python-pycurl
Which worked just fine. The reason I used 3.5 is because there wasn't a similar package for 3.6. So you might want to try finding Pycurl on your package manager for the version you're using and install it that way instead.

python script that came with program doesn't seem to find the program module

I just installed Gubbins using their homebrew instructions. Everything seemed to go smoothly and gubbins is now in /usr/local/Cellar/gubbins/1.1.1/bin/gubbins. I'm supposed to be able to use it by running their script run_gubbins.py and giving it an input file. But I get the following error:
>$ /usr/local/Cellar/gubbins/1.1.1/usr/bin/run_gubbins.py test.fasta
Traceback (most recent call last):
File "/usr/local/Cellar/gubbins/1.1.1/usr/bin/run_gubbins.py", line 25, in <module>
from gubbins import common
ImportError: No module named gubbins
Looking inside the run_gubbins.py script I see that the first things it does is
import sys
sys.path.append(".")
import argparse
from gubbins import common
So what might be happening? How come the script within a program package is not recognizing the program it came with? Is there anything I can do to fix this? Thank you so much.
Install homebrew from brew.sh
Open a terminal and enter these commands
curl https://bootstrap.pypa.io/ez_setup.py | python - --user
export PATH=~/Library/Python/2.7/bin:${PATH}
easy_install pip
pip install --user dendropy
pip install --user biopython
pip install --user reportlab
brew tap homebrew/science
brew install http://sanger-pathogens.github.io/gubbins/fastml.rb
brew install http://sanger-pathogens.github.io/gubbins/gubbins.rb

Python ImportError: No module named serial

I have installed Python 2.7.5 on Ubuntu 12.4 on a DELL LATITUDE E4300 64 bit and ran:
sudo pip install pyserial
nevertheless when running:
sudo python main.py
I receive the following error message:
Traceback (most recent call last):
File "main.py", line 4, in <module>
from mySerial import *
File "/home/oscar/ath10k/tools/sanity_test/src/mySerial.py", line 6, in <module>
import serial
ImportError: No module named serial
I looked on other posts but none of them helped me to solve this problem. I don't know what else to do I also ran:
sudo -H pip install pyserial
and
sudo pip install pyserial --upgrade
Any help will be greatly appreciated.
Kind regards.
Oscar.
On my ubuntu 14.4 with python 2.7 as default, I installed pyserial for python3 (which my IDE is using actually) with the help of following command:
sudo apt-get install python3-serial
Your script name is exactly like module name, change mySerial.py to something else.
I solved this by installing pyserial from source code instead than doing it with pip.
I do not know why it works this way and when using pip it prints error messages.

Categories

Resources