Remove and Reinstall Cygwin

Maybe time has come to remove Cygwin to free up space or to start over. Cygwin does not support an uninstall program but can be done manually.

  1. Open command prompt with administrator privilages
  2. Type takeown /r /d y /f cygwin64
  3. Type lcacls cygwin64 /t /grant everyone:f
  4. Type rmdir /s /q cygwi64
  5. Regedit and delete HKEY_CURRENT_USER_Software_Cygwin
  6. Regedit and delete HKEY_LOCAL_MACHINE_Software_Cygwin
  7. Delete shortcut on desktop
  8. Restart

Download latest setup-x86_64 and run it. Do not install everything! Only start by installing ‘gcc-core’, ‘make’, ‘openssl’ ‘openssh’, ‘vim’ and ‘python3.8’. Also, include the ‘python3.8-crypto’ file which will save you a lot of pain when adding packages with pip3 which rely on cryptography package. It is quite easy to go down a rat hole when a dependency fails and you get disheartened when a lot of red messages appear on screen. There are times you need to use the Cygwin setup program to install specific packages.

Open Cygwin terminal and type python should start python 3.8 shell.

Cygwin Virtualenv

Over time the number of Python packages installed becomes too high to understand their dependencies on each other. I tried to add a package and changed my environment where I lost the list of previously installed packages. Rather than go into detail all I can say is that it was a lesson learnt.

Because it is sometimes difficult to fix an issue and is time consuming I wanted to create a virtual environment in Cygwin so I could develop new applications and not impact my normal day to day setup.

Here are the steps I used to create a virtual environment in Cygwin:

  1. Check which pip to use for the Python version you use.
  2. pip3 install virtualenv
  3. mkdir PythonApp
  4. cd PythonApp
  5. virtualenv PythonAppVenv
  6. Check new environment folder PythonAppVenv created in PythonApp folder
  7. Activate the virtual environment by typing source PythonAppVenv/bin/activate
  8. (PythonAppVenv) should appear on the left side of the name prompt
  9. Check list of packages is different to normal list with pip3 list
  10. Install a new package and it will only add it to the virtual environment
  11. Check the PythonAppVenv lib/python3.8/site-packages folder or type pip3 list
  12. Once you are finished, you deactivate the virtual environment using the command deactivate