{"action":"created","issue":{"url":"https://api.github.com/repos/oTree-org/otree-core/issues/275","labels_url":"https://api.github.com/repos/oTree-org/otree-core/issues/275/labels{/name}","comments_url":"https://api.github.com/repos/oTree-org/otree-core/issues/275/comments","events_url":"https://api.github.com/repos/oTree-org/otree-core/issues/275/events","html_url":"https://github.com/oTree-org/otree-core/issues/275","id":57687549,"number":275,"title":"Launcher virtualenv should be easily accessible from the command line","user":{"login":"oTree-org","id":5423929,"avatar_url":"https://avatars.githubusercontent.com/u/5423929?v=3","gravatar_id":"","url":"https://api.github.com/users/oTree-org","html_url":"https://github.com/oTree-org","followers_url":"https://api.github.com/users/oTree-org/followers","following_url":"https://api.github.com/users/oTree-org/following{/other_user}","gists_url":"https://api.github.com/users/oTree-org/gists{/gist_id}","starred_url":"https://api.github.com/users/oTree-org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oTree-org/subscriptions","organizations_url":"https://api.github.com/users/oTree-org/orgs","repos_url":"https://api.github.com/users/oTree-org/repos","events_url":"https://api.github.com/users/oTree-org/events{/privacy}","received_events_url":"https://api.github.com/users/oTree-org/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/oTree-org/otree-core/labels/consultant","name":"consultant","color":"009800"},{"url":"https://api.github.com/repos/oTree-org/otree-core/labels/p1","name":"p1","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-02-14T09:28:27Z","updated_at":"2015-02-14T23:02:51Z","closed_at":null,"body":"People who install oTree with the [launcher](https://github.com/oTree-org/otree-launcher) will sometimes need to run oTree commands from the command line that are not available through the GUI, such as:\r\n\r\n```\r\n./otree startapp\r\n./otree test\r\n./otree shell\r\n```\r\n\r\nHowever, currently, if they try any of these commands, it will give an `ImportError`, because the launcher installs oTree inside a virtualenv in `~/.otree-launcher` or (on Windows) `%AppData%/oTree-launcher`. This virtualenv must be activated before the `otree` script will work.\r\n\r\nOn Mac/Linux the command is:\r\n\r\n`~/.otree-launcher/venv/bin/activate`\r\n\r\nOn Windows (cmd), it is:\r\n\r\n`%APPDATA%/otree-launcher/venv/Scripts/activate`\r\n\r\nFor windows users on PowerShell the command may be more complicated; I can't figure it out at the moment. Something like:\r\n\r\n`powershell -noexit \"$env:APPDATA\\otree-launcher/venv/Scripts/activate\"`\r\n\r\nI see a few ways to address this issue:\r\n\r\n**(1) add documentation that the user should either explicitly activate this virtualenv before they run the otree script, or add it to their command shell's startup file.**\r\n\r\nThe problem is that it's cumbersome to type this command manually each time before you run the oTree command. And although Mac/Linux make it easy to add something to `.bash_profile`, it is not straightforward on Windows (requires editing the registry: http://superuser.com/questions/302194/automatically-executing-commands-when-a-command-prompt-is-opened)\r\n\r\n**(2) make the launcher install oTree onto the system-wide Python (not virtualenv)**\r\n\r\nThe main target audience for the installer is a beginner programmer who is installing oTree on their personal computer (not a server) so probably doesn't need multiple virtual environments. So maybe it is reasonable to use the system Python installation.\r\n\r\nHowever, this option would not be desirable for people who have limited permissions on their machine, or developers who need a virtual environment. So, if we go with this option, we should probably provide an option in the GUI to select a different Python interpreter than the system-wide one (by browsing to the Python executable in the virtualenv). We probably also want to give an option to skip the \"First run setup\". That way, more skilled users could clone the repo themselves and install their own virtualenv, but use the convenient launcher GUI for `runserver`/`resetdb`, etc. this is something I personally would find useful.\r\n\r\n**(3) button in the launcher GUI to open the command window**\r\n\r\nThis would launch the system's terminal/command prompt to the current project dir, and automatically run the venv activate script.\r\n\r\nThis seems like a fairly nice solution in theory, I just don't know how hard it is and what complications could arise.\r\n\r\n**(4) add to the repo an `activate_venv.py` script**\r\n\r\nThis script could sit in the root of the project and the user could manually run it when they need to activate the virtualenv. They could also edit this file to change the path to the venv. (This idea is not my favorite but I am mentioning it anyways)\r\n\r\nThoughts?"},"comment":{"url":"https://api.github.com/repos/oTree-org/otree-core/issues/comments/74395846","html_url":"https://github.com/oTree-org/otree-core/issues/275#issuecomment-74395846","issue_url":"https://api.github.com/repos/oTree-org/otree-core/issues/275","id":74395846,"user":{"login":"leliel12","id":299010,"avatar_url":"https://avatars.githubusercontent.com/u/299010?v=3","gravatar_id":"","url":"https://api.github.com/users/leliel12","html_url":"https://github.com/leliel12","followers_url":"https://api.github.com/users/leliel12/followers","following_url":"https://api.github.com/users/leliel12/following{/other_user}","gists_url":"https://api.github.com/users/leliel12/gists{/gist_id}","starred_url":"https://api.github.com/users/leliel12/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leliel12/subscriptions","organizations_url":"https://api.github.com/users/leliel12/orgs","repos_url":"https://api.github.com/users/leliel12/repos","events_url":"https://api.github.com/users/leliel12/events{/privacy}","received_events_url":"https://api.github.com/users/leliel12/received_events","type":"User","site_admin":false},"created_at":"2015-02-14T23:02:51Z","updated_at":"2015-02-14T23:02:51Z","body":"Another way is add the \"activate_this.py\" inside the otree runner, but is more easy to simple call the bat and open the console... also this behavior was a bug for me when i writing the launcher"}}