-
Notifications
You must be signed in to change notification settings - Fork 17
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
Doesn't load correct python on Mac OS X #1
Comments
Hi, I don't have a Mac so it hasn't been tested very well with that OS. If you save your project (command You might also want to enable debug logging. You can do so from sublime's console executing this:
Hope that helps. |
Thanks for the feedback. So I tried a few different things. Firstly, I created a completely new environment to make sure I wasn't messing things up somehow. I've installed In Sublime Text, I created a new project and activated the virtualenv. As a result, my project file looks as follows:
I then did what you suggested and imported
The build itself generates the following error:
So I'm not sure what's going on. Looks like things are configured, but when running the Any idea what's going on? PS: As you can see, I didn't get the debug messages that you did either. Not sure why though. Thanks! |
Try this in your script, and see what you get: import sys
print(sys.executable, sys.version, sys.path) Update: Sorry, forgot the most important (the path). |
So from ST3, this is the output:
Same output from the Terminal:
As you can see, the Terminal picks up the right Python, whereas ST3 isn't. And I can confirm that the right environment is still activated in ST3, since the project file includes the Hoping it's something small, as this would be an awesome plugin to have functioning on my Mac. Thanks! |
I'm experiencing the same problems. I'm running ST3 in Mac OS 10.9, and also using homebrew python as the default. |
So... played a bit with it with no success by now. |
Ah yes, I also launch ST3 from the terminal. |
I have same issue — wrong python and no modules.
though it's installed in venv. Python shows different version too.
|
Creates a new ~/.virtualenv just fine and can even be activated from the shell, but build system doesn't seem to reflect the updated sys.path in sublime. |
+1 Same with me Terminal picks correct python virtualenv$ python -m sys -c 'print(sys.executable)'
/Users/mrokade/.virtualenvs/gplaces/bin/python ST3 doesnt. When I run print(sys.executable) from the script, this interpreter is picked up/usr/bin/python |
+1 |
Same issue. Let me know if I can help test. PS - works great on Linux!! |
I believe this is due to how Sublime runs subprocesses on OS X. From exec.py in the Default.sublime-package: if shell_cmd and sys.platform == "win32":
# Use shell=True on Windows, so shell_cmd is passed through with the correct escaping
self.proc = subprocess.Popen(shell_cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, startupinfo=startupinfo, env=proc_env, shell=True)
elif shell_cmd and sys.platform == "darwin":
# Use a login shell on OSX, otherwise the users expected env vars won't be setup
self.proc = subprocess.Popen(["/bin/bash", "-l", "-c", shell_cmd], stdout=subprocess.PIPE,
stderr=subprocess.PIPE, startupinfo=startupinfo, env=proc_env, shell=False)
elif shell_cmd and sys.platform == "linux":
# Explicitly use /bin/bash on Linux, to keep Linux and OSX as
# similar as possible. A login shell is explicitly not used for
# linux, as it's not required
self.proc = subprocess.Popen(["/bin/bash", "-c", shell_cmd], stdout=subprocess.PIPE,
stderr=subprocess.PIPE, startupinfo=startupinfo, env=proc_env, shell=False) The rationale for using a login shell presumably being that since OS X has multiple sources of PATH, inside a coder's tool like Sublime it should use whatever PATH you have in your .bash_profile. An unfortunate side effect is that it'll clobber whatever supplied PATH the build system passes along with the exec request. I'll put together a pull request. |
Sublime's normal exec routine runs commands in a login shell to ensure the PATH from .bash_profile et al are respected. In this case, we explicitly do want the supplied path rather than the shell path, so this patch rewrites the kwargs to the exe routine to avoid being run in a login shell.
Sublime's normal exec routine runs commands in a login shell to ensure the PATH from .bash_profile et al are respected. In this case, we explicitly do want the supplied path rather than the shell path, so this patch rewrites the kwargs to the exe routine to avoid being run in a login shell.
Someone else can test this fix? |
I'll try to test it out tonight. |
Excellent! Seems to be working on my system (El Capitan). Installed the package via Package Control and then overwrote the commands.py file with the one provided by @snaily and now when I activate a virtualenv from within ST3, I can access the libraries installed via pip. I double-checked by running some test code with the virtualenv activated and deactivated and it behaves as required. So this seems to be resolved! |
Rewrite exec command on OS X. Fixes #1.
I just merged the PR and released a hotfix update. |
Great! 👍 |
Woohoo!
|
I have tried the latest version on Mac OS, but I still cannot build my project properly using virtualenv. When I do virtualenv:activate, I didn't get anything and the building still does not work. Any suggestions? |
Hi there,
I was hoping this might be the easy answer to my problems of deal with virtualenvs within ST3. I followed all the instructions and it doesn't seem to work on Mac OS. When I try to activate a virtualenv from the command palette, it correctly lists the environments. There don't seem to be any issues with running the activate command; however even when I choose the
Python + Virtualenv
build system specifically, it doens't seem to run python within the activated environment.Any suggestions as to how to diagnose the issues? Would be great to get this working.
Thanks!
The text was updated successfully, but these errors were encountered: