Troubleshooting#


Table of Contents#


Anaconda#

  • [ d ] FAQ

  • [ d ] Troubleshooting

  • [ d ] Anaconda Navigator - Troubleshooting


AWS#

[ b ] Hidden dangers of duplicate key violations in PostgreSQL and how to avoid them


Flask#

Flask Tutorial in Visual Studio Code - Create and run a minimal Flask app: https://code.visualstudio.com/docs/python/tutorial-flask#_create-and-run-a-minimal-flask-app

Development Server - Address already in use: https://flask.palletsprojects.com/en/latest/server/#address-already-in-use


Git Bash (Git for Windows)#

  • [ d ] Requirements

  • [ g ] Diagnosing Performance Issues

  • [ g ] FAQ


GitHub#

  • [ d ] Why is Git always asking for my password?

  • [ d ] Troubleshooting: Remote origin already exists


Jupyter#

[ d ] What to do when things go wrong


pgAdmin#

  • [ d ] Support

  • [ d ][ g ] Issues

How to setup the PostgreSQL binary path in pgAdmin#

Under Construction

pgAdmin

  • File > Preferences > Paths > Binary paths > PostgreSQL Binary Path

Windows Binary Path

  • C:\Program Files\PostgreSQL\11\bin

macOS Binary Path

  • Interactive Installer by EDB: /Library/Applications/PostgreSQL/11/bin

  • Homebrew: /opt/homebrew/Cellar/postgresql/11/bin

  • Postgres.app: /Applications/Postgres.app/Contents/Versions/latest/bin

Resources to pass along to the student


Postgres#

OperationalError: (psycopg2.OperationalError) could not translate host name "...@127.0.0.1" to address: unknown server error#

This problem arises when the user-set password for the default PostgreSQL user postgres includes a special character such as the at sign @.

To solve this problem, you may change the password for the default PostgreSQL user postgres to one which does not include special characters such as the at sign @ or you may percent-encode their current password as follows:

config.py

database_password = 'myPassword@'

notebook.ipynb

from sqlalchemy import create_engine
from config import db_password
import urllib.parse

database_name   = ''
database_string = f'postgresql://postgres:{urllib.parse.quote(database_password)}@127.0.0.1:5432/{database_name}'
engine          = create_engine(database_string)
df.to_sql(name='table_name',
          con =engine)

What follows is context surrounding this problem:

The document on SQLAlchemy Database URLs states,

“As the URL is like any other URL, special characters such as those that may be used in the password need to be URL encoded to be parsed correctly.. Below is an example of a URL that includes the password “kx%jj5/g”, where the percent sign and slash characters are represented as %25 and %2F, respectively:

postgresql+pg8000://dbuser:kx%25jj5%2Fg@pghost10/appdb

The encoding for the above password can be generated using urllib.parse:

>>> import urllib.parse
>>> urllib.parse.quote_plus("kx%jj5/g")
'kx%25jj5%2Fg'

The document on PostgreSQL Connection Strings states,

“The connection URI needs to be encoded with percent-encoding if it includes symbols with special meaning in any of its parts. Here is an example where the equal sign (=) is replaced with %3D and the space character with %20:

postgresql://user@localhost:5433/mydb?options=-c%20synchronous_commit%3Doff

Resources


Scikit-Learn#

[ d ] 10.3 Controlling randomness


SQLAlchemy#

Percent-encoded passwords: https://docs.sqlalchemy.org/en/20/core/engines.html#escaping-special-characters-such-as-signs-in-passwords

PostgreSQL connection string: https://docs.sqlalchemy.org/en/20/core/engines.html#postgresql

SQLite connection string: https://docs.sqlalchemy.org/en/20/core/engines.html#sqlite


Visual Studio Code#

Terminal Basics - Working directory: https://code.visualstudio.com/docs/terminal/basics#_working-directory

Terminal Here (extension): https://marketplace.visualstudio.com/items?itemName=Tyriar.vscode-terminal-here

“By default, the terminal will open at the folder that is opened in the Explorer. Split terminals on Windows will start in the directory that the parent terminal started with. On macOS and Linux, split terminals will inherit the current working directory of the parent terminal.”


To Review#

CondaVerificationError and ClobberError on Windows#

Unverified

Upon attempting to create a new Conda environment

Preparing transaction: done
Verifying transaction: failed

the following error messages in several variations prevent its completion.

CondaVerificationError: The package for pywin32 located at C:\Users\<username>\anaconda3\pkgs\pywin32-302-py37h2bbff1b_2 appears to be corrupted. The path

'Lib/site-packages/pywin32_system32/pythoncom37.dll'
'Lib/site-packages/pywin32_system32/pywintypes37.dll'
'Library/bin/pythoncom37.dll'
'Library/bin/pywintypes37.dll'

specified in the package manifest cannot be found.
ClobberError: This transaction has incompatible packages due to a shared path.
  packages: ...
  path: ...

It may be worth attempting to

  • revert Conda dependency anaconda in Conda environment base from version custom to the latest distribution

  • properly uninstall and reinstall Anaconda distribution

These resources may be helpful in troubleshooting related issues.

Character Encoding#

Different kinds of dashes#

Three unique dash-like symbols

import unicodedata

print(f"{'Symbol':<10} {'Code Point':<10} {'Category':<10} {'Name':<10}")
for point in '-—–':
  print(f"{chr(ord(point)):<10} "
        f"{format(ord(point), '04x'):<10} "
        f"{unicodedata.category(point):<10} "
        f"{unicodedata.name(point)}")
Symbol     Code Point Category   Name      
-          002d       Pd         HYPHEN-MINUS
—          2014       Pd         EM DASH
–          2013       Pd         EN DASH

You can produce a symbol given its code point.

print(u'\u002D')
print(u'\u2014')
print(u'\u2013')
-
—
–

And you can produce a symbol’s code point given the symbol literal.

print(hex(ord('-')))
print(hex(ord('–')))
print(hex(ord('—')))
0x2d
0x2013
0x2014

On macOS, you can produce each symbol literal in the following way.

  • Hyphen-minus: there is a dedicated key on the keyboard for this symbol

  • Em Dash: Option + Hyphen-minus + Shift

  • En Dash: Option + Hyphen-minus

GitHub#

Including a large file in one’s GitHub repo with Git LFS#

Resources

Git LFS

Make sure to run

git lfs track large.csv        &&
git add .gitattributes         &&
git commit -m ".gitattributes" &&
git push

prior to running

git add large.csv           &&
git commit -m "large.csv"   &&
git push

Setting up GitHub Pages#

Flask#

Starting a local web server with Flask#

Documentation

Quickstart

In the terminal, navigate to your local project directory and run

python -m flask

or

flask run

and then open a new tab in your web browser and navigate to the URL

localhost:5000

JavaScript#

Avoiding CORS Cross Origin Resource Sharing problems with a local server#

PostgreSQL+pgAdmin#

[Errno 1]: Operation not permitted: '/Users/username/Desktop' when I attempt to access my Desktop from within pgAdmin and there is a red lock icon next to my Desktop folder icon in pgAdmin#

This problem appears to have a relation to the user permissions including which parts of the filesystem the user is allowed to read from and write to.

On macOS Monterey, navigate to the following setting and verify the pgAdmin has the correct permissions:

  • System Preferences > Security & Privacy > Privacy > Accessibility

  • System Preferences > Security & Privacy > Privacy > Files and Folders

TensorFlow#

TensorFlow Installation#

Under Development

macOS + conda-forge? Local CPU TensorFlow in a Conda environment on macOS

Alternative Avenues

Windows#

How to take a screenshot on Windows#

How to use Python on Windows#

Under Development