How do I install modules such as (pandas/ openpyxl) [duplicate] - python

This question already has answers here:
How do I use installed packages in PyCharm?
(14 answers)
Closed 1 year ago.
Okay so I have just started to learn python. I use pycharm to currently write the code. I just dont understand how I install modules. For example I wish to load in excel files. I have seen that either pandas or openpyxl can be used, but I dont get how I get access to these modules. All videos I have seen online just type either install openpyxl or pip install pandas. 'install' does not come up as a valid function on my window. Other functions come up highlighted before I complete them and install seems to be like its not recognized and once executed I get a syntax error for install. Do I have to download these modules before installing?

pip install <package>
needs to be written in terminal, not in code window. In the bottom left corner you have "terminal" button, press it, and in new window type pip install whatever you want.

Related

What can I do to install Pygame? [duplicate]

This question already has answers here:
How to install pygame?
(4 answers)
Unable to install Pygame using pip
(27 answers)
Closed 22 days ago.
I can't use pygame package in Pycharm. I have installed it with pip but I can not use it. When I tried to install it from the error that appeared in the IDE or from 'Python Packages', it gave me an error. I also tried pip install pygame --pre and it's not working. It says that 'Requirement already satisfied:' but I still can not use it. What should I do?
You should be able to left click on the module. It will display a download packages button. You need internet but should be able to download it. You don't to use the command prompt to install packages. That is only for the python IDLE.
Go here and click install. Pycharm using his own registry of packages.
https://imgur.com/a/AZvsBxJ
So, you're using PyCharm, it likely means it has created a new virtual environment when you created your project, to install packages in that environment it's easiest to either use PyCharm's Package Manager or Terminal. In the case of using Python 3.11 you'd need to supply the --pre flag when installing pygame because the full release of 2.1.3 has not yet been released and 2.1.3.dev8 which is a pre release is the latest one that has 3.11 wheels for installation. More information about that particular thing can be found here: https://stackoverflow.com/a/74188087/14531062
So, on PyCharm you'd want to use the Terminal:
When you switch to it, you'll likely find that it basically is PowerShell (unless you have changed it to use CMD which I doubt) (you'll see PS at the start of each line) so the easiest steps to install pygame would be to type in these commands in this order (press the enter key after each line):
cmd
venv\scripts\activate
pip install pygame --pre
After running these commands pygame should be installed in the correct environment and you should be able to import it without any issues.
Screenshot of how it might look when you follow the steps:

PyCharm install package with square brackets [duplicate]

This question already has answers here:
'pip' is not recognized as an internal or external command
(40 answers)
Closed 1 year ago.
I want to install "stabe-baselines3[extra]"
But in the PyCharm Package installer is only "stable-baselines3" available.
When try to install it via 'pip install' I do get this error:
Translation: 'pip' is not recognized as an internal or external command
How do I get the [extra]?
From: https://github.com/DLR-RM/stable-baselines3
So are you actually needing that additional functionality for atari games?
If so, then you can just use the built-in Terminal to manually install the package you are needing:
Which if you didn't already know, can be found right here:
Otherwise, you can just use stable-baselines3, as you have already found is available within the package manager.
The terminal has to be used. Reason the terminal hasn't worked is because in the settings 'Start directory' hasn't been the Python Scripts folder but the main-file folder.
After that folder change the pip install command worked!

import pygame no module named 'pygame' [duplicate]

This question already has answers here:
Python error "ImportError: No module named"
(37 answers)
Closed 3 years ago.
I'm using a mac and typed
pip install pygame
into my terminal.
The terminal said the download was successful, but when I use
import pygame
in IDLE, I get an error.
I've looked at questions similar to this one and have not found an answer. Does anyone know what the problem could be?
Your terminal is referring to a different environment that the one that your IDLE environment refers to. For example Pycharm saves its python packages in the venv folder by default. Pip installing a package through the terminal would not allow you to import the package inside pycharm because you have not installed it in the venv environment.
To fix this, I believe you should use the command
source activate
in order to activate the environment that IDLE is running. You should be able to install it, and import it then.

invalid syntax when trying to install pip [duplicate]

This question already has answers here:
Why does "pip install" inside Python raise a SyntaxError?
(7 answers)
Closed 4 years ago.
i'm trying to install this package called 'exceptions' in command prompt for Python, yet all i get is "invalid syntax". what seems to be the issue? i tried things like
pip18 install exceptions (i'm using version 18 of pip)
pip -m install exceptions
enter image description here
enter image description here
The pip command isn't a python statement, it's a command like python and so it should be entered at the c:\Users\L31308> prompt.
pip install exceptions looks right, but unfortunately there doesn't appear to be an exceptions module to be installed. The packages are normally stored on the PyPI web site, sometimes referred to as "the cheese shop".
Perhaps if you could explain why you want to import this module and what it's supposed to do we might be able to find a fuller answer for you.

Install Python packages and directories (windows) [duplicate]

This question already has answers here:
How to change the path of Python in Spyder?
(5 answers)
Closed 4 years ago.
I am new to configuring and setting up Python from scratch.
I have installed Anaconda and I plan to use Spyder for python development. I also have a older version of Python installed on the same machine elsewhere.
I needed to get my hands on a package to use in Spyder which I needed to download and install.
I downloaded and installed pip directly from the website and then I used this in the command line of the older python install to obtain the package I required.
However I don't understand how I go about making this available to Spyder. I believe it works on a folder structure within it's own directory and I am unsure how to change this to get the package I have already downloaded.
I thought I might be able to copy it across, or point it at the directory where the package was downloaded to but I cannot work out how to do this.
I also tried using pip from within Spyder to work but it cannot find it.
Can you please let me know what I need to check?
from the command line can you use pip? Btw I believe python 3 comes with pip included anyway you need to make sure it's in your path
Find pip.exe on your computer, then add its folder (for example, C:\Python27\Scripts) to your path (Start / Edit environment variables). Now you should be able to run pip from the command line. Try installing a package:
pip install httpie
Try to:
Open Anaconda Prompt and then do: pip install whatever - to install wheels
If you want to install spyder the open Anaconda Navigator - and you should be in the home tab - then highlat spyder and press install - thats all.
There are other ways but within spyder ipython console you can install package like.
In [1]: import pip
In [2]: pip.main(['install', 'module-name'])

Categories

Resources