#πŸ”’ I have some trouble with python

33 messages Β· Page 1 of 1 (latest)

tender iron
#

for every commend i use (like pip) i get the same message i added python to enviorment variables.

errant nimbusBOT
#

@tender iron

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

silent crypt
#

That's because you're already in python

#

You're no longer in CMD

tender iron
#

why pip doesnt work here?

silent crypt
#

pip isn't part of the language, it's an executable

#

try print("Hello world")

#

It only executes code

tender iron
#

damn, so how do i install things? i tried through vscode

silent crypt
#

Simply exit python with ctrl d

#

or open a new cmd

#

win + r cmd

peak tree
silent crypt
#

the type pip

#

Cool

tender iron
silent crypt
#

You night want to try out venv if you don't want bloat

tender iron
#

this is what im trying to install lol

silent crypt
#

You know the trick to open cmd in a folder right?

#

It's already installed

#

comes with python

tender iron
#

so just virtualenv venv

silent crypt
#

Yeah you gotta create and activate an environment

#

make sure you're in the right folder (not the python program files)

#

then when you use pip, it'll only install in that folder

tender iron
#

'virtualenv' is not recognized as an internal or external command,
operable program or batch file.

#

should i do pip install virtualenv first?

inner kelp
#

!virtualenv

errant nimbusBOT
#
Virtual environments

Virtual environments are isolated Python environments, which make it easier to keep your system clean and manage dependencies. By default, when activated, only libraries and scripts installed in the virtual environment are accessible, preventing cross-project dependency conflicts, and allowing easy isolation of requirements.

To create a new virtual environment, you can use the standard library venv module: python3 -m venv .venv (replace python3 with python or py on Windows)

Then, to activate the new virtual environment:

Windows (PowerShell): .venv\Scripts\Activate.ps1
or (Command Prompt): .venv\Scripts\activate.bat
MacOS / Linux (Bash): source .venv/bin/activate

Packages can then be installed to the virtual environment using pip, as normal.

For more information, take a read of the documentation. If you run code through your editor, check its documentation on how to make it use your virtual environment. For example, see the VSCode or PyCharm docs.

Tools such as poetry and pipenv can manage the creation of virtual environments as well as project dependencies, making packaging and installing your project easier.

Note: When using PowerShell in Windows, you may need to change the execution policy first. This is only required once per user:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
inner kelp
tender iron
#

thanks

errant nimbusBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.