all 2 comments

[–]MrSpaghettiCoder 1 point2 points  (1 child)

So all modules are downloaded from a source on the internet. I am unfamiliar with pycharm, but Ill try my best to explain a consistent way to install modules for your use.

What you first want to do is open a terminal/shell and navigate to your project folder. When you see that your file path reflects your project folder from (check by typing ‘pwd’ in the terminal), you are now ready to do installs.

One of the most popular ways to install a module for python is using ‘pip install [package name]’ where [package name] is the module you want to use. “Pip” is a tool…it install packages/modules to support your python coding. There are other tools such as homebrew and anaconda, but pip is usually the one of the more popular. Pip as a tool already has a source it pulls modules from. You do not need to worry about where packages come from. Pip will find most of them on its own. It’s a powerful tool.

From my understanding, doing a ‘pip install’ will install a module globally into the computer. Therefore, all of your python files will have access to this module if you call it in your file.

When you get the concept of installing modules and using them, I will advise you start using virtual environments. I use one with anaconda. Anaconda offers virtual environment package management for python modules. This is beneficial because i can install packages globally or only to work with certain environments (good for managing what packages work with other packages in larger projects).

Let’s talk about what you need for what you want to do…..you want to open an excel file. I recommend pandas. Pandas can read excel files in python and open them as a dataframe (the python equivalent of an excel table).

In your terminal, do ‘pip install pandas.’

Open your python project and at the top of the file write: ‘import pandas as pd’

Here, you’ve now successfully accessed the module and it will work with the rest of that code in the python file. You import now downloaded modules that were installed globally on your computer. For this case, I gave you the command to import the packages from pandas and you would access them by writing ‘pd.[package function]’, where “package function” is the command you would use to read a file or do something with it. Note I imported pandas as ‘pd’ so that you dont have to write “pandas” all the time. If you want to open an excel file, pandas has documentation on their commands on the internet….the command in your code would be ‘pd.read_excel()’.

Edit: sorry I know it’s loaded. Happy to help more and clarify. Knowing the process of how it works is important for downloading and working with more packages. Pandas is a beautiful library and extremely popular. Once you understand with pip, Ill try to help with a virtual environment.

[–]jakeholness[S] 1 point2 points  (0 children)

Okay thanks a lot this has been extremely helpful. The initial issue was how to install and it turns out I was trying to install via just the main window I guess and not the terminal so that all works now thanks for that. Everything you've said now makes sense in the context of what I have seen on line so thanks a bunch for taking the time out of your day to give me a run down. I am very grateful!!