Posts Python Notes
Post
Cancel

Python Notes

Configuration

  1. Use pip3 to install packages for python3.7 while use pip for python3.6.
  2. Install a certain package to the designated postion:
    1
    
    pip install -t /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (package name)
    
  3. See the path concerning one certain version of python:>import sys print(sys.path)
  4. Get the list of modules in one version of python:>help(modules)

Programming Errors

  1. >arrayOfLines = fr.readlines(fr)
  2. >mat = empty(3, 2)
  3. When showing syntaxError, check the parenthesis.

Python Notes

  1. reload is no longer used in python3, to do this, we need to import importlib first.>import importlib importlib.reload(module)
  2. os.path.dirname(__file__) works in .py file but not in ipython or Jupyter notebook. In Jupyter notebook, directly use the relative path.
Updated Feb 23, 2020 2020-02-23T15:14:05-06:00
This post is licensed under CC BY 4.0