prof-rossetti / intro-to-python

An Introduction to Programming in Python
Other
97 stars 244 forks source link

Investigate IDEs #94

Closed s2t2 closed 2 years ago

s2t2 commented 3 years ago

The integrated terminal in VS code is non-functioning / hard to configure, so we need an easier tool students can use for local development. An IDE would be fine.

PyCharm is a possibility. The TAs like Spyder. Here are some instructions we can give students for Spyder, but I need to take more time to verify we could use Spyder in conjunction with environment variables, etc. So removing this content from the COSC 010 Local Dev Setup Guide for now. TODO: add text editor / IDE instructions to that doc.


The goal is to have access to a text-editing application of choice, which we'll use to create and edit files of Python code (i.e. text files written in the Python Language and ending in the ".py" extension).

Unless you already have a text editor of choice, let's use the [Spyder](https://www.spyder-ide.org/) application which provides not only text editing capabilities, but also an integrated development environment (IDE) capable of running Python programs as well.

If the Spyder application didn't get installed alongside Anaconda, feel free to download Spyder separately from the website.
s2t2 commented 3 years ago

Looks like this may be a possibility:

https://docs.spyder-ide.org/current/faq.html#run-terminal

Activate your conda environment by typing the following in your terminal (or Anaconda Prompt on Windows): conda activate <ENVIRONMENT-NAME>. Then, type spyder to launch the version installed in that environment.

Looks like it requires a pip install spyder, but it does launch the Spyder window.

One-time environment setup:

conda create -n cosc-010-env python=3.8
conda activate cosc-010-env

# verify things are working
python --version
pip list

# install additional packages
pip install python-dotenv
pip install spyder
spyder
Screen Shot 2021-08-27 at 6 21 06 PM

It does launch the Spyder program, but the console seems to have different packages installed? Maybe not what we're looking for. Maybe they just mean launch Spyder if it has already been installed in the conda environment.

s2t2 commented 3 years ago

If we go through Anaconda Navigator, we can create a new environment that way. Then try to launch Spyder (or VS Code?) using the selected environment.

Screen Shot 2021-08-27 at 6 26 24 PM Screen Shot 2021-08-27 at 6 27 00 PM Screen Shot 2021-08-27 at 6 30 49 PM

Although I think this is the same process as installing spyder inside the environment.

We probably would still need to install packages via pip from the command line. And then activate the env and run spyder.

s2t2 commented 3 years ago

Let's try a new test...

conda create -n my-spyder-env python=3.8
conda activate my-spyder-env

python --v
pip list

cd ~/projects/prof-rossetti/daily-briefings-py
pip install -r requirements.txt 

pip install spyder
spyder

Let Spyder open.

Select the proper repo directory from the top right corner.

Screen Shot 2021-08-27 at 7 59 03 PM

From the Spyder terminal, verify:

pwd
Screen Shot 2021-08-27 at 8 00 23 PM

OK so far so good.

It seems it does not respect modular invocation though.

Screen Shot 2021-08-27 at 8 01 45 PM

OK nevermind about selecting the project from the top right I guess we need to "Open File" from the top left.

Screen Shot 2021-08-27 at 8 05 41 PM

Then press play and see:

Screen Shot 2021-08-27 at 8 07 41 PM

Bummer. We need to figure out a way to run with modular invocation. At this point it seems easier to use the real terminal to run the file.

s2t2 commented 3 years ago

Trying PyCharm (community version) https://www.jetbrains.com/pycharm/download/download-thanks.html?platform=mac&code=PCC

Can download a project right from Github.

It just worked great. Created a virtual env for me from the requirements.txt. Installed all packages. Ran the weather service fine.

Screen Shot 2021-08-29 at 2 40 02 PM Screen Shot 2021-08-29 at 2 40 48 PM Screen Shot 2021-08-29 at 2 41 23 PM Screen Shot 2021-08-29 at 2 41 45 PM

Can install packages as well: https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html#packages-tool-window

s2t2 commented 2 years ago

This thread confirms PyCharm is a good IDE option. We should consider adding PyCharm as an option to the dev tools setup guide.