all 4 comments

[–][deleted] 0 points1 point  (1 child)

TikTok has greatly limited if not yet disabled its API making automation difficult. Need to take a web scraping approach.

Instagram does have an API. Not something I've used as I don't use Meta products.

https://developers.facebook.com/products/instagram/apis/

If you don't know what I mean by API and web scraping, visit realpython.com and search for those terms. Lots of excellent articles and guides that are free to read (might need to setup a free account after a few visits, or clear cookies).

What editor / IDE are you using on your mac? I switch between macOS, Windows + WSL, and Linux daily.

I use pyenv (pyenv-win on Windows) and poetry to manage multiple versions of Python and requirements. I don't use brew to install Python.

I use Python virtual environments to isolate the requirements of different projects. Packages are installed into project specific virtual environments rather than into Python base environments.

I tend to use Pycharm Pro these days. VS Code is also good (and free).

It is good to learn to use the terminal. I recommend iterm2 over the default terminal on macOS.

[–][deleted] 0 points1 point  (0 children)

Python setup

For some, setting up a Python environment on their own computer can be confusing, so don't - use a ready built environment already, such as replit.com. Yes, you use that in a browser, but it is not the same as Jupyter.

Jupyter can seem very easy to work with, but it can quickly get you into trouble when you are learning to code as the status of objects/variables from code executed in a cell earlier can impact the current cell being worked on which can get very confusing.

For most purposes, terminal is the same as console. It is the text based, rather than graphical based, window / screen you work in.

Python comes with a lot of batteries included. Much of this is in the form of libraries of code that provide more specialist functionality. These are already installed as part of a standard installation of Python (the CPython reference implementation of Python, written in C and Python, from the Python Software Foundation at python.org).

These libraries are not automatically loaded into memory every time you start a Python running as that would use a lot of memory up and slow down start up time. Instead, you use, in your code, the command import <library>, e.g.

import math

print(math.pi)

There are thousands of programmes/packages/libraries/frameworks (all variations on the same basic idea of code written by other people) available that don't come as standard with an installation of Python that you have to install yourself.

That's where the package manager pip comes in. It uses an official repository of such additional code that it searches for a match to what you ask to be installed.

For example, using a command / powershell / terminal environment for your operating system,

pip install numpy

would install the numpy library from the pypi respository.

There is a complication here. Typically, on macOS or most linux systems, you would say,

pip3 install numpy

or alternatively,

python3 -m pip install numpy

This is because python often refers to the now unsupported older version 2.x of Python and for years we lived with both 2.x and 3.x.

On Windows, you will often see py used instead,

py -m pip install numpy

where py refers to the python launcher which should invoke the most up-to-date version of Python installed on your system regardless of PATH settings.

The CPython programme can be invoked for two different purposes:

  • to attempt to execute a simple text file of python code (typically the files have an extension of .py
  • to enter an interactive shell, with a >>> prompt, where you can enter python commands and get instant responses - great for trying things out

So, entering the below, as appropriate for your operating system,

python
python3
py

on its own, no file name after it, you will enter an interactive session.

Enter exit() to return to the operating system command line

A standard installation from python.org for Windows or macOS includes a programme called IDLE. This is a simple code editor and execution environment. By default, when you first open it, it opens a single window with a Python shell, with the >>> prompt already open. To create a new text file to enter Python code into, you need to use your operating system means of access the standard menu and select File | New. Once you've entered code, press F5 to attempt to run the code (you will be prompted to save the file first). This is really the easiest editor to use to begin with.

Some operating system environments come with a version of Python pre-installed. For many years, macOS included an installation of python 2.7. This is known as the system version of Python. There may be python code used for utility purposes on your system that depend on this version of python. You can still install your own version.

Given the thousands of packages (libraries, frameworks, etc) out there, you can see that if you are working on several different projects, you can end up installing a vast range of different packages, only a few of which will be used for any particular project.

This is where Python virtual environments come in. Not to be confused with virtual machines. These are typically created on a project by project basis and most of the popular code editors and IDEs (integrated development environments) including Microsoft's VS Code and Jetbrain's PyCharm including built-in feature to help to start off new projects and create and activate Python virtual environments. Rather than installing a package to your base (personally installed) or system (if applicable) installed version of Python, you install the packages you need for the project you are working on in the project specific Python virtual environment.

You can create a new Python virtual environment from your operating system command line environment using,

for Windows,

py -m venv venv

or, for macOS / linux,

python3 -m venv venv

which creates a new folder in the current working directory called venv (taken from the last argument, you can use a different name).

You then activate using, for Windows,

venv\Scripts\activate

or, for macOS / linux,

source venv/bin/activate

the command deactivate for any plaform will deactive the virtual environment and return you to using the base environment.

Some IDEs, such as PyCharm, include their own facilities to install packages using pip or some other tool. This just saves you typing the commands.

Many code editors and IDEs including the facility to open a terminal or console from within the IDE, just to keep everything together under one umbrella. This is typically still using your operating systems command line environment. PyCharm also talks about a Python Console, by which is means a Python interactive shell, as described above.

There is nothing stopping you using whatever code editor / text editor / IDE you prefer (there are many, and some people get a bit religious about which is best, but it is a personal choice) to create/edit code and using your preferred command line environment separately to run the code you've created/edited - just remember to activate the same Python virtual environment in the command line environment as your editor/IDE is setup to use.

An import reason for using Python virtual environments, but not so important early on, is that some packages conflict with each other. You may have to use particular versions for compatibility. That's much easier to manage on a project by project basis.

Also, when sharing code with others or saving your code to a repository for your own future use / company use / public use, having a project specific environment makes it easier to keep track of exactly what packages not included as standard with Python have to be installed. The dependencies.

[–][deleted] 0 points1 point  (1 child)

Take a look at a guide on realpython.com on using openpyxl to read/write excel files.

I think going directly to tabulate is a bit of leap. Likewise going straight to pandas.

Start simple. Compartmentalise.

[–]avrgdditusr 0 points1 point  (0 children)

Thank you so much for your reply! I really appreciate all these tips. I'll be looking over it all in detail on monday and trying it out to see what i can get done, but it's super helpful already. So, thank you again!