Christopher Juckins

SysAdmin Tips, Tricks and other Software Tools

User Tools

Site Tools


python_notes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
python_notes [2017/08/29 08:36] – created juckinspython_notes [2020/04/08 14:40] juckins
Line 1: Line 1:
 ==== Python Notes ==== ==== Python Notes ====
  
-Use "pip" to manage python packages.  +__8 April 2020__ 
 + 
 +Upgraded Chrome via yum to version 81.0.4044.92 and now check_envoy.pl fails. 
 + 
 + 
 +   
 +__11 December 2019__ 
 + 
 +Upgraded Chrome via yum to version 79.0.3945.79 and now check_envoy.pl fails. 
 + 
 +Did the following as root to fix: 
 + 
 +  # /usr/local/bin/pip3 uninstall chromedriver-binary 
 +  # /usr/local/bin/pip3 install chromedriver-binary 
 +  # /usr/local/bin/pip3 install pip-upgrade-outdated 
 +  # pip-upgrade-outdated 
 +   
 +  # find /usr -name "chromedriver" -exec ls -l {} \; 
 +   
 +  /usr/lib/python3.6/site-packages/chromedriver 
 +  /usr/local/lib/python3.6/site-packages/chromedriver_binary/chromedriver 
 + 
 +  # chmod 755 /usr/local/lib/python3.6/site-packages/chromedriver_binary/chromedriver 
 + 
 +Note that both **/usr/bin/pip3.6** and **/usr/local/bin/pip3.6** exist on the system now...needs to be fixed. 
 + 
 + 
 + 
 +---- 
 + 
 +With CentOS7.7, python3 can load from base.  Do the following to fix previously-installed IUS release: 
 + 
 +  # yum remove python36u 
 +  # yum install python3 
 +  # yum remove ius-release 
 + 
 +  * Then follow instructions for installing local python packages to ensure all still work.   
 +  * If you have pip problems, uninstall/reinstall using instructions at https://pip.pypa.io/en/stable/installing/ 
 +  * Ensure pip3.6 is in your $PATH or you have a sym link to it (/usr/local/bin) in /usr/bin 
 + 
 +__Install Python 3.6 on CentOS 7__: 
 +  * https://linuxhint.com/install_python3_centos7/ 
 +  * https://janikarhunen.fi/how-to-install-python-3-6-1-on-centos-7.html 
 + 
 +Do some local configuration for my scripts (su - root): 
 +  pip3.6 install --upgrade pip 
 +  pip3.6 install --upgrade httplib2 
 +  pip3.6 install pymysql 
 +  pip3.6 install selenium-wire 
 +  pip3.6 install chromedriver 
 +  pip3.6 install chromedriver_binary 
 +  pip3.6 install dictor 
 +  pip3.6 install wget 
 +  pip3.6 install pip-upgrade-outdated 
 +   
 +To update all pip packages: 
 + 
 +  # pip_upgrade_outdated 
 + 
 +Note that https://pypi.org/project/pip-upgrade-outdated/ is a good resource to update all PIP packages. 
 +   
 +Download and install geckodriver (see https://github.com/mozilla/geckodriver/releases) 
 + 
 +As root, copy geckodriver to /usr/local/bin and ensure permissions are 755 
 + 
 +Notes at https://stackoverflow.com/questions/40208051/selenium-using-python-geckodriver-executable-needs-to-be-in-path 
 +   
 +Notes about [[https://www.tutorialspoint.com/python3/python_database_access.htm|Python database access]] 
 + 
 +Python3.7 on Fedora 28: 
 +  * dnf install python37 
 +  * wget https://bootstrap.pypa.io/get-pip.py 
 +  * python3.7 get-pip.py 
 +  * python3.7 -m pip install requests 
 + 
 +Use "pip" to manage python packages:
  
   # yum install python2-pip   # yum install python2-pip
 +
 +To list installed python modules:
      
-  pip list+  pip list
      
 +[[https://docs.python.org/3/howto/logging.html|Logging in python]]
 +
 +  logging.basicConfig(format='%(asctime)s %(message)s', filename=log_file, level=logging.DEBUG)
 +  logging.debug('This message should go to the log file')
 +  logging.info('So should this')
 +  logging.warning('And this, too')
 +
  
 +[[https://realpython.com/python-pep8/|Write beautiful python code with PEP-8]]
python_notes.txt · Last modified: 2023/04/05 08:56 by juckins