Sample Header Ad - 728x90

How to activate python venv in a non-bash shell?

0 votes
1 answer
3127 views
I see most tutorials/online sources advice using either source or . (a bash built-in) to activate a python venv. For example, this page suggests to do the following in Linux: cd ~/ . bin/activate (whereas in Windows, it's just cd\ and activate) But I need to activate a venv inside a docker/Dockerfile, and bash may not be available (e.g. with podman OCI images). As underlying distros such as Debian-based ones adopt PEP 668 , pip commands without the venv in old Dockerfiles cause an error that "This environment is externally managed" . The suggested way now seems to be use venv. Considering the fact that source is specific to certain shells, my questions are: *Is it always necessary to use source to activate a venv in Linux?* *If so, why and what's the proper way to activate venv in a general non-bash shell?* *In particular, what's the proper way to use venv on pip commands in generic Dockerfiles?*
Asked by tinlyx (1072 rep)
Jun 15, 2023, 02:05 PM
Last activity: Jun 16, 2023, 04:41 AM