Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8093

Python • Re: error: externally-managed-environment

$
0
0
You can also use a “shebang” line which points to the environment’s Python interpreter,
i.e. #!<path-to-venv>/bin/python (the <path-to-venv> MUST be a fully qualified path).
This is how scripts installed into the virtual environment work.
I am not sure how you mean by that, what scripts would be installed into the virtual environment.
I suggest you look at your venv.
Thanks for the clarification of what you meant by "installed". Yes, it does appear that "pip installed" things do create wrappers' for apps within the virtual environment with shebangs which explicitly refer to that virtual environment.

I wasn't aware of that, and it explains why virtual environments cannot simply be renamed, moved, or copied for other users.

Such fully qualified shebangs are appropriate for things 'pip' installs into the virtual environment, but I wouldn't consider them appropriate for user created programs which aren't 'pip' installed, for the reasons stated.

And that's particularly so for for Python programs which are published so others may use them.

I have downloaded, copy and pasted, Python source code which does have shebangs which point to directories only the author has and have then had to go through all that source to rectify that issue, make them universally usable by anyone. That is an inconvenience which didn't have to be.

Statistics: Posted by hippy — Tue Jul 08, 2025 2:05 pm



Viewing all articles
Browse latest Browse all 8093

Trending Articles