Python virtual environment

Setup a virtual environment

python -m venv my-env

activate the environment

source my-env/bin/activate

exist the environment:

deactivate

You can use absolute path to run the script, the result is same with virtual environment.

[root@beaming-text-1 my-env-folder]# ./my-env/bin/python3.7 test.py

The interpreter python3.7 under the folder my-env is symlink file point to your interpreter installed in system path just like /usr/local/bin/python3.7.

[root@beaming-text-1 my-env-folder]# ls -l my-env/bin/python3.7
lrwxrwxrwx 1 root root 24 Dec 11 20:40 my-env/bin/python3.7 -> /usr/local/bin/python3.7

You can’t use the symlink interpreter in command statements for php exec function, or you will fail to run it and get status 126.

PHP – Concatenate string array

PHP_EOL is a constant in PHP that represents the end-of-line character sequence for the platform on which the PHP script is running. It stands for “end of line” and provides a way to add line breaks in a platform-independent manner.

$finalStr = "";
foreach ($output as $key => $value) {
	$finalStr = $finalStr . $value . PHP_EOL;
}
echo $finalStr;
Categories: PythonWeb

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments

Explain Code
: explain the code you input to help you to understand it.

X
0
Would love your thoughts, please comment.x
()
x