-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting up virtualenv on mac #2106
Comments
I believe that for this issue, the page linked has the information required to get this working. I am having trouble what might be unclear, as in the page linked we see:
And from our
If the user wants to see virtual environments on Mac then, she could simply add .virtualenvs to the |
@DonJayamanne do we want to add ~/.virtualenv to the list of default venvFolders? |
That location isn't specifically typical as the OP claims as virtual environments have no default unless you use some tool that provides some default. |
Closing as this isn't an issue with the extension but the OP not realizing they are using tools that are making assumptions. |
I'm the OP of the question @karthiknadig posted above. In addition, I tried adding my virtualenv location to the configuration, but select interpreter still didn't find the virtualenvs. Is there some specific set of steps that I need to take to add the virtualenv paths and make sure that the config is re-parsed by VSCode? Merely saving the config does not seem to be updating the items in the select interpreter list. I'd like to get this working on Mac as this is about the only thing that keeps me coming back to atom where the simplicity of As a long time user of visual studio, it feels like VSCode is skating too close to the legacy Microsoft/Java config style here and needs to lean a bit in the command line direction. For instance, why can't I just |
@davidthewatson what do you mean by "tried adding my virtualenv location"? Are you talking about As for picking up an explicitly activated environment, we probably could, it's just no one has really asked for it. 😄 I've opened #2124 to discuss the idea of reading the |
I'm similarly lost, on a couple things. Pardon my ignorance - I thought I had vscode and python all figured out, but clearly I know nothing :) On windows, for approx. ever now, my go-to workflow has been to use virtualenvwrapper-powershell with all projects. Something like
This opens vscode, which inherits the virtualenv and all the linting/etc/etc uses what's installed in that venv. If I hit "install linter" on first run (when it's not installed yet), that gets installed into that virtualenv. Cool. I thought this is how I was doing things on Mac too, but I'll admit, I haven't been on mac in a while. I'm now setting up a new machine, and when I try to do the same thing, So for one, does this workflow (terminal>cd to project dir>workon myenv>code .) simply not work on Mac like it does on windows with powershell? Can I make it work that way? And for two - OP seems to be having trouble with shift-cmd-p>select interpreter not finding his virtualenvs in ~/.virtualenvs. My .bash_profile has had in it, for the longest time,
So why does that part work fine for me but not OP? |
I can set I've gone through many attempts at this where I blank out both the user and workspace settings and start from a clean slate setting venvPath to no avail.
Also, fwiw:
One thing I'm confused about is what is the difference or purpose of having venvFolders and venvPath? If there's an easy way to hookup a docker image to each python project config, I'm happy to just abandon virtualenvs since I run all of this code on kubernetes dev, staging, prod environments anyhow and derive from python 3 images as a result. |
That I can help with: fire up code and shift-cmd-P "Install code command in path" - that'll add a symlink at /usr/local/bin/code But it doesn't seem to be the case that it inherits virtualenvs! I guess in your case, you're using exclusively python3 'venv', but placing those at ~/.virtualenvs. I'm using primarily virtualenvwrapper, which by my configuration, places my NOT-A-'venv's at that same location. Doing it my way, invoking code with
the virtualenv isn't inherited at all. I think I can manually set my interpreter and restart code, but that's sort of cumbersome vs just bouncing around virtualenvs on the terminal. On the other hand, if I make a 'venv' with
code sees the venv directory inside my current project dir and uses that environment by default. So anyway, if you're using python3 venv, just store the venv in your project directory and it seems vscode likes that. But if you're trying to use virtualenv/virtualenvwrapper, or else just need to keep your 'venv's in a separate dir, I'm not sure how to make either of those work right. |
Thanks @alexwhittemore. I can now start code from the command line. That's progress. However, I use virtualenvwrapper with pyenv: I'd rather not store the virtualenvs in the project directory just to accommodate vscode. Instead, I'd prefer to figure out the bug where (according to the documentation) the various configs I've reported above should work. |
@davidthewatson Now in your And #118 is tracking the idea of supporting @alexwhittemore you want #2124 for us to automatically use an activated virtual environment (we do automatically detect and use virtual environments that are in a top-level directory of your workspace folder). |
@davidthewatson Ahhh - you're doing something I'm not used to (and don't understand) FWIW, my workflow for making python3 virtualenvs is And yes, I agree - storing environments in the project dir seems like the wrong approach to me for lots of reasons, but fwiw, it SEEMS to be what python's venv system assumes - maybe for just for simplicity in the venv documentation, maybe for best practice, I'm not sure. @brettcannon That does look like what I'm after! I'll pursue my own parts of this discussion on those issues, thanks! |
@alexwhittemore virtualenv predates venv as the external tool that provided virtual environments to Python. venv is the stdlib solution to the same problem to make it work more smoothly and proper integrate it into Python instead of virtualenv having to hack around stuff. 😉 And the And putting the virtual environment in the project is very common because you are expected to have an environment per project, so the thinking is why put it anywhere else? |
That was my impression, but I think the logic there breaks down on discipline. (Not to argue, just musing:) That makes perfect sense to someone doing one-off projects or working locally, or whatever, but probably a lot less so to someone sticking to some kind of git workflow. My personal feeling is, absent git, yeah, why would virtual environment files live anywhere else? But if my project is in git, I REALLY prefer to avoid adding anything to .gitignore that's not strictly necessary - the pip list to rebuild my virtualenv should live there with the code, but definitely not all the extraneous stuff wasting space in my repo. I feel like that's where the logic splits. |
The .virtualenvs directory in the user's home is the canonical design for virtualenvwrapper AFAICT: http://virtualenvwrapper.readthedocs.io/en/latest/install.html#shell-startup-file One of mine looks as you'd expect:
@brettcannon I tried changing the venvPath from the relative to the absolute in user settings:
This had no effect. The virtualenv is neither prompted nor selected when starting the debugger. |
FWIW, I don't store my virtualenvs in project directories because IMO project directories should be specifically non-vendor content and vendor content should be clearly marked |
Agree about leaving virtualenvs in the project directory. On the one hand I totally get the "well where else" argument, but I don't know why Python decided with venv to do it that way, since, yeah, SCM nightmare. |
@alexwhittemore everyone simply ignores the directory, e.g. |
Question from survey feedback:
The text was updated successfully, but these errors were encountered: