Unable to pip3 install in virtual env

2,459 views
Skip to first unread message

Fraser Clark

unread,
May 10, 2021, 10:02:48 AM5/10/21
to NetBox
Hi,

I have a fresh install of netbox on centos 7 and when I run the following commands:

source /opt/netbox/venv/bin/activate
pip3 install django-auth-ldap

I get the following error:

ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/opt/netbox-2.11.3/venv/lib/python3.6/site-packages/pyasn1'
Check the permissions.

Any ideas would be appreciated.

Cheers,
Fraser

Jeremy Stretch

unread,
May 10, 2021, 10:21:13 AM5/10/21
to Fraser Clark, NetBox
The user as which you're executing "pip3 install" doesn't have permission to write to the virtual environment directory on disk. It's likely owned by root, and you need to either run pip as root or re-assign ownership of the path to the non-root user.

Jeremy Stretch
Distinguished Engineer, NS1
Office of the CTO
 
website: ns1.com
email: jstretch@ns1.com
 
twitterlinkedin
 
banner


--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/CA%2BnqaD1u0KgshGSmOHrPzW%3DkUv517LKkmOhRN651crSf6R4A%3DQ%40mail.gmail.com.

Fraser Clark

unread,
May 10, 2021, 10:30:42 AM5/10/21
to Jeremy Stretch, NetBox
Hi Jeremy,

Thanks for the info.
Before activating the venv, I ran sudo -i then activated it. After that I could install it properly.

Cheers!
Fraser

Genius Dev

unread,
May 11, 2021, 5:59:25 PM5/11/21
to Fraser Clark, Jeremy Stretch, NetBox
Why not have his own virtualenv to run the pip3 install -r requirements ?

Brian Candler

unread,
May 12, 2021, 4:20:34 AM5/12/21
to NetBox
> Why not have his own virtualenv to run the pip3 install -r requirements ?

Because then netbox wouldn't be able to use it: the objective was to install django-auth-ldap for netbox to use.

However there's a simpler and better way: create a file "local_requirements.txt" containing "django-auth-ldap".  Then when you run netbox's ./upgrade.sh script, it will install this package in the venv it creates.
Reply all
Reply to author
Forward
0 new messages