Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This question is based on creating a venv environment called 2005env in your acc

ID: 3875508 • Letter: T

Question

This question is based on creating a venv environment called 2005env in your account under the cs lab ubuntu image. The environment is created using the bash command:

A) What command will activate the 2005env environment from outside the 2005env directory?

B) If you use the bash command python at the normal ubuntu bash shell, you will launch version 2.7.12 of python. If you run the command python from the activated 2005env environment, what python version do you get?

C) If you run a pip install from inside the 2005env environment to install a package, such as Flask, what additional pip command does the pip install ask you to consider?

D) Once you used pip to install a package inside the virtual environment, in what directory did pip place the package files?

E) The bash PATH environment variable lists the locations bash looks for executable commands. Activating the 2005env environment should change the first entry in the bash PATH environment variable. What is the first directory in the PATH when 2005env is activated?

Explanation / Answer

Below answers are specific to python and python3 installed on my system which is "Ubuntu 17.04"

, you'll have to determine the python and python3 version on the cs lab ubuntu machineimage.


python@python:~$ python --version
Python 2.7.13 --> This in your case would be 2.7.12
python@python:~$ python3 --version
Python 3.5.3 --> This you must determine

If python3 -m venv 2005env command give below message then you must install venv as shown:
python@python:~$ python3 -m venv 2005env
The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.

apt-get install python3-venv

You may need to use sudo with that command. After installing the python3-venv
package, recreate your virtual environment.

Failing command: ['/home/python/2005env/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']

INSTALL:
sudo apt-get install python3-venv

***********************************ANSWERS***************************************************

A) What command will activate the 2005env environment from outside the 2005env directory?

Given that you are in your home directory (/home/python here) and your 2005env is under home directory below command activates the environment
python@python:~$ pwd
/home/python
python@python:~$ . 2005env/bin/activate
(2005env) python@python:~$

Once you virtual environment is activated it will show the name of virtualenvironment before the prompt i.e. (2005env)

B) If you use the bash command python at the normal ubuntu bash shell, you will launch version 2.7.12 of python. If you run the command python from the activated 2005env environment, what python version do you get?
You must run python command on the virtual environment on your lab machine to get correct python version, for me it is Python 3.5.3
(2005env) python@python:~$ python
Python 3.5.3 (default, Nov 23 2017, 11:34:05) [GCC 6.3.0 20170406] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()(2005env) python@python:~$ python
1. You can also run the python --version command in activated environment to see the default python version.
(2005env) python@python:~$ python --version
Python 3.5.3

C) If you run a pip install from inside the 2005env environment to install a package, such as Flask, what additional pip command does the pip install ask you to consider?


You need to run this command on your lab machine to check what additional pip command is being prompted. Most probably it might prompt you to upgrade pip to latest version. Below is the command, your pip version will be different.
/opt/letsencrypt/letsencrypt-auto stderr: You are using pip version 8.1.1, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command
OR
It might not prompt you at all if pip version is latest.

D) Once you used pip to install a package inside the virtual environment, in what directory did pip place the package files?


pip will install package files under site-packages directory. Full path below:
./2005env/lib/python3.5/site-packages/


You can quickly check: Install flask or requests package from activated virtualenvironment and once it is successfully installed, run below command, it will tell you the location where package is installed. Package is installed under site-packages and executable is installed under bin.
(2005env) python@python:~$ find 2005env/ -name flask
2005env/lib/python3.5/site-packages/flask
2005env/bin/flask

E) The bash PATH environment variable lists the locations bash looks for executable commands. Activating the 2005env environment should change the first entry in the bash PATH environment variable. What is the first directory in the PATH when 2005env is activated?

First entry is /home/python/2005env/bin depending you where virtual environment 2005env is installed.
You can check is using below commands, once inside activated virtual environment and then again after deactivating it.

(2005env) python@python:~$ echo $PATH
/home/python/2005env/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
(2005env) python@python:~$ deactivate
python@python:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote