question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MIssing venv activation step in install guide

See original GitHub issue

Environment

  • Python version: 3.8.5
  • Nautobot version: 1.0.0b2

Steps to Reproduce

  1. Follow install instructions for venv

Expected Behavior

$ echo $PATH
/opt/nautobot/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

Observed Behavior

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

Need to activate the venv to view it in the $PATH

$ source $NAUTOBOT_ROOT/bin/activate
$ echo $PATH
/opt/nautobot/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jathanismcommented, Mar 11, 2021

Ahhh okay… I see why it’s out of phase now. We just revised the docs the other day to streamline creation of the user and the virtualenv.

We were creating the virtualenv prior to sudo to nautobot before, which would cause /opt/nautobot/bin to be present already. The default ~/.profile checks for the presence of $HOME/bin and automatically prepends $PATH with it if that directory is found.

So, need to change the order of things again so that source ~/.bashrc comes AFTER creation of the virtualenv.

0reactions
pke11ycommented, Mar 11, 2021

I’m fairly sure I followed the steps as documented. Here’s the shell history for reference.

$ sudo useradd --system --shell /bin/bash --create-home --home-dir /opt/nautobot nautobot
$ sudo -iu nautobot
$ echo "export NAUTOBOT_ROOT=/opt/nautobot" >> ~/.bashrc
$ source ~/.bashrc
$ echo $NAUTOBOT_ROOT
/opt/nautobot
$ python3 -m venv $NAUTOBOT_ROOT
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

Doing as you suggested from a new session worked as documented.

$ sudo -iu nautobot
$ echo $PATH
/opt/nautobot/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
Read more comments on GitHub >

github_iconTop Results From Across the Web

There is no activate when I am trying to run my virtual env
According to Python doc, the installation step is $ python3 -m pip install --user virtualenv $ python3 -m venv env.
Read more >
How To Set Up a Virtual Python Environment (Windows)
Where's My Python? Install virtualenv; Create a Virtual Python Environment; Activate the Environment; Add Libraries and Create a requirements.txt File ...
Read more >
Rebuilding a Virtualenv - PythonAnywhere help
1) Use a requirements.txt file to record what packages you're using¶ · Activate your virtualenv, using source /home/myusername/path/to/virtualenv/bin/activate or ...
Read more >
Installing and using virtualenv with Python 3
Overview Virtualenv is a tool used to create an isolated Python ... After it's installed and activated, run the which python3 command as ......
Read more >
venv — Creation of virtual environments — Python 3.11.1 ...
A virtual environment may be “activated” using a script in its binary directory ( · In order to achieve this, scripts installed into...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found