Skip to content

Python Install Tips

Joey Kleiner edited this page Jan 10, 2023 · 16 revisions

python installs:

# display all python installs on ubuntu
ls -ls /usr/bin/python*

# display all python installs on windows
py -0p

# display python version being used
python -V
python --version

pip install

  • pip is the recommended package-management system written in Python used to install and manage software package
pip -V
pip --version

package installs:

# see location(s) of installed packages 
python -m site

# show all installed packages
pip list

# see location of individual package
pip show pandas

# see where python installs your local packages
python -m site --user-site

install packages:

pip install matplotlib

pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pip matplotlib

C:\Users\jklei\AppData\Local\Programs\Python\Python310\Scripts\pip3 install pandasql
C:\users\nrf46657\appdata\local\programs\python\python310\Scripts\pip3 install virtualenv

Setting up Remote-SSH for VS Code

  • Create config file in this location: C:\Users\nrf46657\.ssh\config
    • Can see this by F1 -> Remote-SSH: Settings
  • Populate file with the following
Host deq1.bse.vt.edu
  HostName deq1.bse.vt.edu
  Port 311
  User jkleiner

Host deq2
  HostName deq2
  User jkleiner
  ProxyCommand ssh [email protected] -W %h:%p
  • F1 -> Close Remote Connection to close

Getting set up with python on windows:

  1. Install VS Code Desktop (User Installer 64 bit)
  2. Install Python extension in VS Code
  3. Install latest version of python from web browser (e.g. 3.10.5)
    • Select this interpreter in VS Code


Set Up Virtual Environments

  1. Open a Windows PowerShell
    • Navigate to your home directory PS C:\Users\nrf46657>
  2. Install the python package virtualenv
    • PS C:\Users\nrf46657> py -m pip install --user virtualenv
  3. Confirm install was successful
    • PS C:\Users\nrf46657> pip show virtualenv
    Name: virtualenv
    Version: 20.17.1
    Summary: Virtual Python Environment builder
    Home-page: https://virtualenv.pypa.io/
    Author: Bernat Gabor
    Author-email: [email protected]
    License: MIT
    Location: c:\users\nrf46657\appdata\roaming\python\python310\site-packages
    Requires: distlib, filelock, platformdirs
    Required-by:
    
  4. Create a virtual environment
    • navigate to your project folder
      • PS C:\Users\nrf46657> chdir .\Desktop\GitHub\virtualenv-test-project\
    • create a virtual environment named "virtualenv4"
    • PS C:\Users\nrf46657\Desktop\GitHub\virtualenv-test-project> python -m virtualenv virtualenv4
    created virtual environment CPython3.10.5.final.0-64 in 2672ms
      creator CPython3Windows(dest=C:\Users\nrf46657\Desktop\GitHub\virtualenv-test-project\virtualenv4, clear=False, no_vcs_ignore=False, global=False)
      seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\nrf46657\AppData\Local\pypa\virtualenv)
        added seed packages: pip==22.3.1, setuptools==65.6.3, wheel==0.38.4
      activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
    
    • You can also be explicit in which python install youre using when creating the virtual environment
      • PS C:\Users\nrf46657\Desktop\GitHub\virtualenv-test-project> C:\Users\nrf46657\AppData\Local\Programs\Python\Python310\python.exe -m virtualenv venvName
  5. Activate the virtual environment (in Command Prompt, permissions issue prevents us from being able to activate virtual environments from windows PowerShell, otherwise you could use PS C:\Users\nrf46657\Desktop\GitHub\virtualenv-test-project> virtualenv4\Scripts\activate)
    R:\>cd /d C:\Users\nrf46657\Desktop\GitHub\virtualenv-test-project
    C:\Users\nrf46657\Desktop\GitHub\virtualenv-test-project>virtualenv4\Scripts\activate
    (virtualenv4) C:\Users\nrf46657\Desktop\GitHub\virtualenv-test-project>
    
    • You will now be using the virtual environment untill you:
      1. Close the terminal, or
      2. Use the deactivate command
        • (virtualenv4) C:\Users\nrf46657\Desktop\GitHub\virtualenv-test-project>deactivate
  6. check the pre-installed packages on the virtual environment
    (virtualenv4) C:\Users\nrf46657\Desktop\GitHub\virtualenv-test-project> pip list
    Package    Version
    ---------- -------
    pip        22.3.1
    setuptools 65.6.3
    wheel      0.38.4
    
    (virtualenv4) C:\Users\nrf46657\Desktop\GitHub\virtualenv-test-project>pip install --upgrade pip
    Requirement already satisfied: pip in c:\users\nrf46657\desktop\github\virtualenv-test-project\virtualenv4\lib\site-packages (22.3.1)
    
    • install packages into the environment
    (virtualenv4) C:\Users\nrf46657\Desktop\GitHub\virtualenv-test-project>python -m pip install pandas
    

Clone this wiki locally