DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 19th May 2022
gordon.f gordon.f is offline
Fdisk Soldier
 
Join Date: Oct 2021
Location: Europe
Posts: 70
Default How to activate virtual environment?

Hello,

I was trying to activate the virtual environment that I've created with python as local user and even as root but in both situations I got this message:

ksh: ./myenv/bin/activate: cannot execute - Permission denied

What seems to be the problem?
Reply With Quote
  #2   (View Single Post)  
Old 20th May 2022
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 8,033
Default

I'll guess:

The file you are attempting to execute is not marked as executable in the file system.
Reply With Quote
  #3   (View Single Post)  
Old 20th May 2022
TronDD TronDD is offline
Spam Deminer
 
Join Date: Sep 2014
Posts: 307
Default

You don't execute it, you source it.

'. ./myenv/bin/activate' for ksh.
Reply With Quote
  #4   (View Single Post)  
Old 20th May 2022
gordon.f gordon.f is offline
Fdisk Soldier
 
Join Date: Oct 2021
Location: Europe
Posts: 70
Default

Quote:
Originally Posted by TronDD View Post
You don't execute it, you source it.

'. ./myenv/bin/activate' for ksh.
Thank you very much. It worked.

By the way could you please explain what is the difference between them?
Reply With Quote
  #5   (View Single Post)  
Old 20th May 2022
TronDD TronDD is offline
Spam Deminer
 
Join Date: Sep 2014
Posts: 307
Default

It executes the commands in the current shell.

Why do that and not create a sub-shell? I'm not sure. I assume there is some practical difference that I don't know about.
Reply With Quote
  #6   (View Single Post)  
Old 21st May 2022
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
 
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 1,027
Default

One difference would be that by "sourcing" the commands as in

$ . script

the script can set environment variables that maintain their values in the current shell. Whereas if script is executable and run like

$ script

any environment changes it makes will be lost when the script finishes and you come back to the calling shell.
Reply With Quote
  #7   (View Single Post)  
Old 21st May 2022
TronDD TronDD is offline
Spam Deminer
 
Join Date: Sep 2014
Posts: 307
Default

Is it not possible to make the resulting shell interactive? I thought I've seen some systems do this. Then when you exit the modified sub-shell, you get you original clean environment back.
Reply With Quote
  #8   (View Single Post)  
Old 22nd December 2022
gordon.f gordon.f is offline
Fdisk Soldier
 
Join Date: Oct 2021
Location: Europe
Posts: 70
Default

Dear TronDD,

I was making a search at the forum for Python and saw my question again then read all the messages. For your message at #5, I didn't know at that time. The reason for creating a virtual environment(stand-alone Python in that particular folder) is that you don't want to harm the original Python installation of your system, they said. Let's say there are different projects that require different modules, libraries and by creating a virtual environment you'll make sure that nothing will affect each other. For example sometimes a Flask(a Python web development framework) application requires a deprecated library in order to perform and for some other application that deprecated library is not up-to-date so it doesn't perform.

EDIT/UPDATE: Also when you ship that folder to someone else, they don't have to deal with the dependencies. All the necessary modules/libraries have been already installed by you.

Last edited by gordon.f; 22nd December 2022 at 08:49 AM. Reason: Another use case
Reply With Quote
Reply

Tags
python, venv

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
activate SMP on AMD64 philo_neo71 NetBSD General 8 18th December 2015 03:58 AM
armV7 activate turbo philo_neo71 NetBSD General 0 20th November 2015 03:50 AM
OpenBSD in virtualized environment jjstorm OpenBSD General 13 26th November 2014 06:04 AM
Xfce 4.8.0 desktop environment released J65nko News 4 18th January 2011 05:23 PM
Cannot activate partition in XP. bsdnewbie999 OpenBSD Installation and Upgrading 6 4th May 2009 05:21 PM


All times are GMT. The time now is 09:55 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick