2023 Oct 5th – UQ PUG 2

Welcome to UQ Python User Group! Check out our general information for details about who we are and what we do.

Structure

  1. We start today by adding our names to the table below
  2. Add your questions to this page
  3. This month’s presentation
  4. Finally, we spend the rest of the session answering the questions you’ve brought!

This month’s presentation

https://forms.office.com/r/TTLGSAxS0k

Join us for an informative presentation that delves into the world of Python Integrated Development Environments (IDEs). In this session, we will compare and contrast five popular Python development environments: Spyder, PyCharm, Visual Studio Code (VSCode), Google Colab, and the trusty Command Prompt.

https://www.meetup.com/beginners-python-machine-learning/

Introduce yourself

What’s your name? Where are you from? Why are you here?
Luke Library To learn and attempt help
Mads EAIT Analyse data and hopefully get some help doing that
Taneesha School of the Environment: Conservation Science Learn python coding for ArcGIS
Cameron Library To learn and help!
Nida School of Chemistry & Molecular Biosciences To learn more about python to work on molec bio data
Nick Wiggins Library Here to help and mostly to learn
Annie SENV here to ask all the questions!

Questions

If you have any Python questions you’d like to explore with the group, please put them in a markdown cell, with any code you’d like us to run in a Python cell.

Question 1 - What are some “best practices” or the “correct” way of installing Python for the first time - Annie

I frequently get “path” errors because I’m installed python somewhere and then the IDE can’t find the path to Python (I think), and many “hardcore” programmers don’t like Anaconda - they say it interferes with pip so what is the easiest both initially and later on down the line?

Nick - I’m going to try installing Python and vsCode using these instructions (https://github.com/Oracen/python-intro), and put all the files into one folder as Luke suggested

## Code for Q1

Question 2 - Question - Nida

In Spyder, sometimes when we want to import a module (i.e a .py file that contains certain functions/dictionary), it gives this error:

ModuleNotFoundError: No module named ‘translate’

is this problem related to whether the file that we are trying to import is not saved in our working directory?

How do we set that our working directory is in the place where we saved our file that we want to import as a module?

I saw an Icon called “browse a working directory” in the top right of the Spyder, is this how we set our working directory? Or do we have to do sth else to change our working directory?

Thank you so much

# Access the system (using the module sys)
import sys

# This will display where you can put your modules
print(sys.path)

# This will add another location to the path (another folder where you can load modules)
sys.path = sys.path + ['Location of your modules']

https://www.w3schools.com/python/python_ref_keywords.asp avoid to name your files or variables with these words or python will get confused!

Luke attempting to find answers

The ‘translate’ module is causing a conflict - https://pypi.org/project/translate/

This says you can do pip install to file path? - https://stackoverflow.com/questions/63790682/importing-custom-modules-py-files-into-virtual-environment#:~:text=You%20can%20create%20a%20setup.py%2C%20then%20install%20this,a%20module%20by%20pip%20pip%20install%20-e%20%2Fpath%2Fto%2Ffolder

pip install translate

Question 3 - should you always be using venv (virtual environments) for every new project? - Annie

what are the pros and cons of venv?

## Code for Q3

Question 4 - where does one find packages available in Notable? e.g. google colab doesnt have all packages - Annie

Add more details here

## Code for Q4
help('modules')

Question 5 - Why does it sometimes take so long to use google collab? (i.e when we have to re-run everything again) is it bcs it is run the server which is different from server that we use to run our code with other environment? do we have place to store our .csv file?

## Code for Q5

Question 6 - How do I fix an IndexError: list index out of range? -Taneesha

Writing python code in ArcGIS to loop through a number of geoprocessing tools

numbers = [0,1,2]

letters = ["a","b"]

for i in numbers:
    print(letters[i])

Question 7 - do we have tools for running it line by line in spyder?

Luke you mentioned you were interested in this - feel free to delete once you’ve seen this. https://www.deeplearning.ai/short-courses/langchain-chat-with-your-data/

Thanks Jason. I have a playlist of YTs to work my way through currently. Found a channel where one of the videos I had some success with. This video - https://www.youtube.com/watch?v=wrD-fZvT6UI. So am trying more of his tutorials. Trying to do it without OpenAI API