export LC_ALL=en_US.utf-8
export LANG=en_US.utf-8
Tag Archives: python
ModuleNotFoundError: No module named ‘skbuild’
pip3 install “camelot-py[cv]”
ModuleNotFoundError: No module named ‘skbuild’
pip3 install scikit-build
“Problem with the CMake installation, aborting build. CMake executable is %s” % cmake_executable)
Problem with the CMake installation, aborting build. CMake executable is cmake
python3 -m pip install -U pip
pip3 install opencv-python
pip3 install “camelot-py[cv]”
linux date time calculator
python -c "from datetime import date as d; print(d.today() - d(2020, 10, 24))"
41 days, 0:00:00
ImportError: No module named requests
apt install python-requests
python: No module named SimpleHTTPServer
python -m http.server 1111
Serving HTTP on 0.0.0.0 port 1111 (http://0.0.0.0:1111/) …
clean __pycache__
find /some/python/path -type d -name __pycache__ -exec rm -r {} \+
virtualenv
pip install virtualenv
cd /root/new
virtualenv venv
source venv/bin/activate
possible virtualenv -p /usr/bin/python2.7 venv
site-packages/setuptools/dist.py has no ‘check_specifier’ attribute
pip install setuptools –upgrade
from flaskext.assets import Environment, Bundle
Instead of something like:
from flaskext.assets import Environment, Bundle
use:
from flask_assets import Environment, Bundle
AttributeError AttributeError: ‘bool’ object has no attribute ‘__call__’
Flask-Login has set is_active is_authenticated is_anonymous to property in UserMixin, so we should use current_user.is_authenticated instead of current_user.is_authenticated()
pip Failed building wheel for cryptography when installing Fabric
If you had such errors on your virtualenv:
yum install openssl-devel
CFLAGS=”-O0″ pip install Fabric
src/MD2.c:31:20: fatal error: Python.h: No such file or directory
yum install python-devel
ImportError: No module named flask.ext.script
pip install Flask-Script
SimpleHTTPServer with auth
import BaseHTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
import sys
import base64
key = ""
class AuthHandler(SimpleHTTPRequestHandler):
''' Main class to present webpages and authentication. '''
def do_HEAD(self):
print "send header"
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
def do_AUTHHEAD(self):
print "send header"
self.send_response(401)
self.send_header('WWW-Authenticate', 'Basic realm=\"Test\"')
self.send_header('Content-type', 'text/html')
self.end_headers()
def do_GET(self):
global key
''' Present frontpage with user authentication. '''
if self.headers.getheader('Authorization') == None:
self.do_AUTHHEAD()
self.wfile.write('no auth header received')
pass
elif self.headers.getheader('Authorization') == 'Basic '+key:
SimpleHTTPRequestHandler.do_GET(self)
pass
else:
self.do_AUTHHEAD()
self.wfile.write(self.headers.getheader('Authorization'))
self.wfile.write('not authenticated')
pass
def test(HandlerClass = AuthHandler,
ServerClass = BaseHTTPServer.HTTPServer):
BaseHTTPServer.test(HandlerClass, ServerClass)
if __name__ == '__main__':
if len(sys.argv)<3:
print "usage SimpleAuthServer.py [port] [username:password]"
sys.exit()
key = base64.b64encode(sys.argv[2])
test()
python scan IP range
import sh
print "Scanning..."
# ping range 8.8.8.7 - 8.8.8.9
for num in range(7,10):
# declare ip address
address = "8.8.8." + str(num)
# check if host is alive using PING
try:
# bash equivalent: ping -c 1 > /dev/null
sh.ping(address, "-c 1", _out="/dev/null")
print "ping to", address, "OK"
except sh.ErrorReturnCode_1:
print "no response from", address