#๐Ÿ”’ any python experts here?

39 messages ยท Page 1 of 1 (latest)

sick harness
#

what do I do (Yes I did what it said)

terse barnBOT
#

@sick harness

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.

gentle wing
#

!venv

terse barnBOT
#
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
spring burrow
#

this worked for me

#

if you are using bash ofc

main oriole
main oriole
sick harness
#

API Penetration Testing by APIsec

sick harness
main oriole
sick harness
#

they need me to install jwt_tool

#

and the In-dependencies

main oriole
sick harness
#

omg

#

it work

#

worked*

#

thank you so much, God bless you!

#

wait

#

does it work outside the venv?

#

@main oriole

main oriole
#

are you using the root account or sudo? (hint: you shouldn't be doing so)

sick harness
#

with venv

#

without

main oriole
# sick harness with venv

this is because when you activate a venv it sets up some environment variables that python will use to find the modules local to that venv diir, which you won't have when it's not activated
you can however execute the python binary inside the venv to get the same effect without activating the venv

#

you can do this either by using the full path for that python interpreter binary and then the script that you want to run, but i don't think that is what you will prefer, an easier way is to change the shebang line at the top of your script to use the full/absolute path to that python interpreter binary that is located inside the venv

sick harness
#

?

main oriole
#

that article is also good since it uses all the current best practice (even for the different platforms), at least as far as i have seen

gentle wing
terse barnBOT
#
Python help channel closed for inactivity

This help channel has been closed. 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.