#πŸ”’ venv/bit differences?

72 messages Β· Page 1 of 1 (latest)

maiden sun
#

Hi, I'm trying to run the same code on two different laptops but I think when I was downloading VSC something was different in the process. On one laptop, the interpreter path is Python 3.10.6 64-bit and on the other laptop, the interpreter path is Python 3.9.6 Venv and there's no option for 3.10.6. Is there any way to fix this?

uncut yachtBOT
#

@maiden sun

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.

maiden sun
#

Laptop 1

#

Laptop 2

#

Laptop 1 runs the code smoothly, laptop 2 gives a blank screen and doesn't work

tribal ravine
#

you could try installing python 3.10 on laptop 2

fallen vault
#

Both running the same OS?

maiden sun
#

yes

tribal ravine
maiden sun
#

actually no

#

wait

fallen vault
#

How is python installed on each?

maiden sun
#

laptop 1

#

laptop 2

fallen vault
#

Looks like laptop 2 didn't use homebrew or pyenv to install python and is just using the system install.

maiden sun
#

can i install it with homebrew? because i tried doing that at first and it kept saying there was no command called brew or pip

fallen vault
#

You need to install homebrew first

maiden sun
#

okay sorry i should've clarified -- i installed brew, installed python3 and reinstalled it using brew, but the environments are still different

fallen vault
#

Are you sharing the same venv?

maiden sun
#

no, laptop 1 doesn't use venv

#

i tried to run the code on laptop 1 without venv, but it said i needed venv to run it so that's what i did

fallen vault
#

If you installed python via brew on laptop 2, you may need to reload vscode

maiden sun
#

i reloaded it, it's giving me these option snow

#

however, the libraries that i'm trying to use, customtkinter and CTkListbox, they need to be installed by pip becasue brew doesn't have them

#

when i try to do pip install customtkinter it says command pip not found

fallen vault
#

You need to install python-venv too

maiden sun
#

with brew?

fallen vault
#

Looks like it's already installed. Just create a virtualenv

#

/opt/homebrew/bin/python3 -m venv .venv

maiden sun
#

okay, i did that. but the issue is it's not recognizing pip to install the libraries i need

fallen vault
#

!venv

uncut yachtBOT
#
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
fallen vault
#

activate the venv

#

. .venv/bin/activate

maiden sun
#

i'm just confused because i've never needed to do this with laptop 1 and it works perfectly fine

#

it's saying customtkinter is already installed but doesn't recognize me importing it

fallen vault
#

Don't call /opt/homebrew/bin/python3

#

You've activated the venv, so python should point to .venv/bin/python

#

which is where you installed customtkinter

maiden sun
#

how do i fix that?

fallen vault
#

Just run python code/test

#

If you're using vscode to run the code, select the new venv as the python version.

maiden sun
fallen vault
#

Then run .venv/bin/python3 code/test

maiden sun
#

i tried reinstalling vscode, still not working

maiden sun
fallen vault
#

But you pip installed it

#

it's in .venv/

#

not /opt/homebrew

maiden sun
#

how do i get it to be in .venv/ and not homebrew?

fallen vault
#

That's where it is

maiden sun
fallen vault
#

Oh, that.

#

brew install python3-tk

maiden sun
#

does not work still

fallen vault
maiden sun
#

command not found apparently

fallen vault
#

brew install python-tk

maiden sun
#

okay, that worked. looks different from my version of tkinter but customtkinter is what's not working

fallen vault
#

you have to customize it

maiden sun
#

it's okay tbh, i'll just not use it on laptop 2 because it's complicated

#

the only reason why i wanted to use laptop 2 was because laptop 1 was having issues with buttons not responding when being clicked multiple times

#

but it works if you like move your pointer around a bit and then come back to click it

#

!close

uncut yachtBOT
#
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.