Can't call Stripe on Appengine development server even with latest ssl - python-2.7

I am running into the same issue on my development server. I have already checked out stackoverflow.com/questions/46799365/… and that hasn't worked for me.
python -V
Python 2.7.11
and as soon as I call stripe, I get the Support for test mode requests made with versions of TLS lower than 1.2 has been disabled, and support in live mode will be dropped on June 13, 2018. Please initiate HTTPS connections with TLS 1.2 or later. You can learn more about this at https://stripe.com/blog/upgrading-tls.
My app.yaml has ssl set to "latest" libraries: - name: django version: "1.9" - name: jinja2 version: "2.6" - name: markupsafe version: "0.15" - name: ssl version: latest - name: pycrypto version: latest
So am I supposed to do something with sandbox.py? I think my request is version 2.16.0 because I was getting some other environment issue when it wasn't. Is that he culprit or something else?
Here's the exact error
PermissionError at /
Request req_DrUOViv9FnjhAx: Support for test mode requests made with versions
of TLS lower than 1.2 has been disabled, and support in live mode will be dropped on June 13, 2018. Please initiate HTTPS connections with TLS 1.2 or later. You can learn more about this at https://stripe.com/blog/upgrading-tls.
Request Method:
GET
Request URL:
http://localhost:8080/
Django Version:
1.9.5
Exception Type:
PermissionError
Exception Value:
Request req_DrUOViv9FnjhAx: Support for test mode requests made with versions of TLS lower than 1.2 has been disabled, and support in live mode will be dropped on June 13, 2018. Please initiate HTTPS connections with TLS 1.2 or later. You can learn more about this at https://stripe.com/blog/upgrading-tls.
Exception Location:
lib/stripe/api_requestor.py in handle_error_response, line 178
Python Executable:
/Users/USERNAME/PycharmProjects/PROJECTNAME/virtualenv-dev/bin/python
Python Version:
2.7.11
Python Path:
['/Users/USERNAME/PycharmProjects/PROJECTNAME',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine',
'/Users/USERNAME/PycharmProjects/PROJECTNAME',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine',
'/Users/USERNAME/PycharmProjects/PROJECTNAME/virtualenv/lib/python2.7',
'/Users/USERNAME/PycharmProjects/PROJECTNAME/virtualenv/lib/python2.7/lib-dynload',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/django-1.9',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/jinja2-2.6',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/markupsafe-0.15',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/ssl-2.7.11',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/pycrypto-2.6',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/setuptools-0.6c11',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/protorpc-1.0',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/pytz-2017.2',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.3',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/webob-1.1.1',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/werkzeug-0.11.10',
'/Users/USERNAME/Downloads/google-cloud-sdk/platform/google_appengine/lib/yaml-3.10',
'lib']
Server time:
Sat, 24 Mar 2018 00:43:28 -0500

I spent many hours on this about a month ago. It was a huge pain, but I finally got it to work.
One issue I was having is that Brew does something very annoying with its python versions. It makes python v3 the default so if you type python in the shell you get v3 and not v2. I manually changed the relevant symlinks in '/usr/local/bin' to make v2 the default.
I don't remember all the steps I took, but you'll want your '/usr/local/bin' to look something like this:
openssl -> /usr/local/Cellar/openssl/1.0.2n/bin/openssl
pip -> ../Cellar/python/2.7.14_3/bin/pip2
python -> ../Cellar/python/2.7.14_3/bin/python2
You'll then want to delete your virtualenv's and recreate them.
Note that I don't use python v3 at all, so if you need both v2 and v3 then YMMV.

In addition to using the latest GAE ssl library, when running the application on the local development server you may also need to upgrade your local system's openssl library.
From How do I upgrade my Stripe integration from TLS 1.0 to TLS 1.2? (other specific OS versions are mentioned separately):
If you are using any other system, or are already using brew on OS X, you will need to upgrade your OpenSSL version.
And from How do I upgrade my OpenSSL to support TLS 1.2? (other specific OS versions are mentioned separately):
If you are using any other Linux variant, you will need to ensure that
running openssl version gives a version of at least 1.0.1. If it
does not, you will need to take package updates, and may need to
upgrade to a newer version of your operating system.

Hope this helps someone in this situation....I had my IT admin help me and and it was a combination of things so I'm posting the solution here for my case to save someone else from the same frustration.
These instructions assume you are running these commands all as an Administrator
First remove HomeBrew:
echo -ne 'y\n' | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
sudo rm -rf /usr/local/Homebrew
sudo rm -rf /usr/local/Caskroom
sudo rm -rf /usr/local/Cellar
Remove other Pythons installed (v2)
sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7
sudo rm -rf "/Applications/Python 2.7"
Check for links and remove any you find with Cellar in the path
ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7' | grep 'Cellar'
unlink <## Remove those you found ##>
Re-install Homebrew
echo -ne 'y\n' | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Add in openssl
brew install openssl
brew postinstall openssl
brew link openssl --force
Force Link openssl if needed
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
Add in Python
brew install python#2
brew postinstall python#2
brew link python#2 --force
link openssl and Python (ensure these versions are what you have installed)
ln -s /usr/local/Cellar/openssl/1.0.2o/bin/openssl /usr/local/bin/openssl
ln -s /usr/local/Cellar/openssl/1.0.2o/bin/openssl /usr/local/ssl/bin/openssl
ln -s /usr/local/Cellar/python/2.7.14/bin/python /usr/local/bin/python
Clean HomeBrew Once Installed
brew cleanup -s
brew cask cleanup
brew prune
From here the command showed the correct version
python -c 'import ssl; print ssl.OPENSSL_VERSION'

Related

Python3 and aws-cli version differ

I installed aws-cli following the aws docs
https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-mac.html
$ curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
$ sudo installer -pkg AWSCLIV2.pkg -target /
When I verify their existence I get different Python versions.
$ python3 --version
Python 3.9.6
$ aws --version
aws-cli/2.2.26 Python/3.8.8 Darwin/20.6.0 exe/x86_64 prompt/off
Is this expected?
yeah that's expected. The CLI doesn't use your OS'es python, one is bundled into .pkg file as well as all other dependencies. This simplifies installation, testing and development. you can mess around with your OS's python all you like without breaking the CLI.
the guts of the code for this is here:
https://github.com/aws/aws-cli/blob/v2/scripts/make-bundle
When you use sudo for installing the package you are not referring to what's specific to your user's settings, the python version is one of those settings.
Python 3.8.8 is the system installed version( System Installed
Python 3.9.6 is specific to your user's settings, you might be using pipenv or any other setting which sets the python version for you.
Hence the differences.
$›› sudo python --version
Password:
Python 2.7.16
$›› python --version
Python 2.7.16

Error: Problem: conflicting requests - nothing provides /usr/bin/python needed by python-chardet in CentOS 8

I am using CentOS 8 and want to download a library for Python2.
CentOS 8 has Python3 and its libraries installed by default.
I want to download python-chardet library for Python2. So I tried to install it as below -
$ sudo yum install python-chardet
I got this error -
No match for argument: python-chardet
Error: Unable to find a match: python-chardet
I searched for solution and as per this document you have to download its RPM binary and install it. https://centos.pkgs.org/7/centos-x86_64/python-chardet-2.2.1-3.el7.noarch.rpm.html
Downloading the binary file -
$ wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-chardet-2.2.1-3.el7.noarch.rpm
Using this rpm library I tried to install python-chardet as below -
$ sudo yum install ./python-chardet-2.2.1-3.el7.noarch.rpm
Here I got an error like this -
Error:
Problem: conflicting requests
- nothing provides /usr/bin/python needed by python-chardet-2.2.1-3.el7.noarch
Python version is
$ python -V
$ Python 2.7.16
/usr/bin/python returned this
Python 2.7.16 (default, Nov 17 2019, 00:07:27)
GCC 8.3.1 (RedHat) on linux2
Any help regarding this is much appreciated.
CentOS/RHEL 8 doesn't have any user-facing Python installed by default.
It has Python 3 installed for system apps like dnf, but to use it as a user, you need sudo dnf install python3.
Similarly, Python 2 and everything for it can be installed by using the appropriate package name suffix. To install Python 2 and the module you need:
sudo dnf install python2 python2-chardet
The recommendation/default is that the unversioned python command should not work and you should invoke the desired Python version on the shell by typing python2 instead of python.
If, for whatever reason you need unversioned python command to invoke Python 2, use the alternatives system:
sudo alternatives --set python /usr/bin/python2

rbenv install not downloading ruby version

Installing ruby version with rbenv rbenv install -lreturns the proper list. However
$ rbenv install 2.3.4 -v
fails on the download, even though it can be downloaded via a browser. My hunch about an improper version of openssl (due to some distant memory of having such issues - tls version? - in the past) is supported in verbose mode:
ruby-build: use openssl from homebrew
/var/folders/kV/kVDOSPkcEuqSVnTjenAVRE+++TI/-Tmp-/ruby-build.20170601122915.1010 ~ Downloading ruby-2.3.4.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.4.tar.bz2
curl: (35) error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
error: failed to download ruby-2.3.4.tar.bz2
how to overcome? can I point rbenv to use the downloaded tarball?
The reason is because rbenv use old system curl and old system openssl with it, which knows nothing about protocols TLS v 1.1-1.3. For me, installing new version of curl and openssl with brew did the work:
brew install openssl#1.1
brew install curl
Then add installed curl to your PATH (before default path, which is /usr/bin), and ensure that openssl of actual brew's version is also there (add this to your ./bash_profile or ./zshrc or etc):
export PATH="/usr/local/opt/openssl#1.1/bin:$PATH"
export PATH="/usr/local/opt/curl/bin:$PATH"
You can make sure after relaunch of terminal that latest versions of this programs will be used by trying
which -a openssl
which -a curl
openssl version -a
curl -V
First two commands should output all paths with the programs, but top ones should be brew versions. Last two commands should show latest versions of programs (1.1.0f and 7.55 for me now).
Now try
rbenv install [version]
Works on MacOS Sierra with enabled SIP.

launching cassandra cqlsh python not found

I am trying to install cassandra version 2.2.0 and I found the compatible python version for it is 2.7.10 then I installed it.
when I type in terminal
python2.7 --version
Python 2.7.10
but when I launch cassandra server and want to start cassandra query language shell by typing
root#eman:/usr/local/cassandra# bin/cqlsh
bin/cqlsh: 19: bin/cqlsh: python: not found
how could I fix this issue
thanks in advance
For centos 8 and other similarly:
Install python 2.7
Then, prior to invoking cqlsh, run:
sudo alternatives --set python /usr/bin/python2
It seems that python is not installed on your machine (for whatever reason).
cqlsh shells out to python (in a rather strange way): https://github.com/spiside/cqlsh/blob/6f5b680fed2e48e37107fd1da272e351e5ac257d/cqlsh#L1-L30
Unrelated to this stackoverflow issue, I attempted to fix (and probably fixed) this in the latest version of cqlsh: https://github.com/spiside/cqlsh/commit/a880445ec9d05cfa552928d5a88d1457640456b6
If you can upgrade cqlsh it may fix this.
If you can't upgrade cqlsh any of the following things should fix this:
- If you're on an debian-like system apt-get install python-minimal -- this provides the /usr/bin/python file that seems to be missing (for whatever reason)
- If your package manager has a package which provides the /usr/bin/python symlink, install that
- Otherwise, set up a symlink that's on your path, for example ln -sf /usr/bin/python2.7 /usr/local/bin/python

How to check if mod_wsgi is installed on a shared Apache server?

I am looking into deploying a Django project on a shared server running Apache. This is my first time doing this. I have a shared folder on the server for my work and I have been added to the sudo group so I can install new software.
How do I check via Terminal command line if mod_wsgi is already installed? and preferably what version it is?
I can ssh onto the server, the version of Apache is
$ apache2 -v
Server version: Apache/2.2.22 (Ubuntu)
Server built: Jul 12 2013 13:37:10
$
Any help is much appreciated.
EDIT:
Just for future reference, after I ran the command $ dpkg -s libapache2-mod-wsgi provided by Dirk Eschler it showed me that it was not installed. It returned
Package `libapache2-mod-wsgi' is not installed and no info is available.
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Hope this helps someone else.
To check if it is installed:
$ dpkg -s libapache2-mod-wsgi
In case it is installed, you might check if it's loaded by Apache:
$ apache2ctl -t -D DUMP_MODULES
Though you are on Ubuntu.
This might help someone else on CentOS, Fedora or Red Hat
rpm -q mod_wsgi
Since you're on Ubuntu, which is Debian-based, you can look in /etc/apache2/mods-enabled.
if you working with python in Red Hat
search this for mod_wsgi installed or not yum search python3-mod_wsgi
or search this for module is loaded or not rpm -q python3-mod_wsgi