pghilardi / atom-python-virtualenv

Python virtualenv support for Atom
MIT License
16 stars 6 forks source link

Plugin doesn't see any virtualenvs #18

Closed lcd1232 closed 7 years ago

lcd1232 commented 7 years ago

I installed this plugin but it doesn't find any virtualenvs. I'm using mac os and zsh with virtualenvwrapper. lsvirtualenv shows me list of virtualenvs.

Atom: 1.16.0 x64 Electron: 1.3.13 OS: Mac OS X 10.12.4

$ lsvirtualenv
deploy
======
site
====
test
====

screen shot 2017-05-16 at 00 05 19

pghilardi commented 7 years ago

@lcd1232 ,

Could you try something for me? Go to the settings of this plug-in and add an additional virtualenv path that points directly to the directory of one of your virtualenvs. For example, if your virtualenvs are located in ~/virtualenvs and you have two virtualenvs ~/virtualenvs/one and ~/virtualenvs/two you should add the following:

~/virtualenvs/one;~/virtualenvs/two

Tell me if after the manual configuration the plug-in list some virtualenv.

Thanks!

appukuttan-shailesh commented 7 years ago

I am getting a similar problem. When I open atom via the terminal, the virtualenvs are available. But the same isn't available when I try to open atom via the ubuntu launcher.

This has previously been reported here, and possibly fixed here. But still getting the same issue.

appukuttan-shailesh commented 7 years ago

@pghilardi : I tried what you suggested. I have two virtualenvs (plus miniconda) and I added the path to one of those in the settings. Now when I open atom via the launcher, I get miniconda and the virtualenv that I specified. And when opening atom via the terminal, I get all three environments.

(p.s. previously I could only get miniconda and no virtualenvs when opening atom via the launcher)

pghilardi commented 7 years ago

@appukuttan-shailesh ,

Thanks for the prompt reply! So probably its something related to the WORKON_HOME variable. I have some questions:

Are you using the virtualenvwrapper? What is the content of your WORKON_HOME of virtualenvwrapper?

appukuttan-shailesh commented 7 years ago

Yes, I am using virtualenvwrapper.

echo $WORKON_HOME

gives me:

/home/shailesh/environs

(which is where I store all my virtualenvs) and lsvirtualenv gives me:

py27_main
=========
test_env
========

@pghilardi : Bigger thanks to you for looking into this so quickly. Let me know if you need me to try out anything. Keen to get this working soon.

pghilardi commented 7 years ago

@appukuttan-shailesh and @lcd1232, the quickest solution and the one that I have implemented is to allow to specify the WORKON_HOME variable. To do this, you must check to use virtualenvwrapper and then add a forced value to the WORKON_HOME variable, in your case: /home/shailesh/environs or more short: $HOME/environs

I don't know why this variable is not being loaded in the situation that you have described, but for now I solved this way to not block you.

Test updating your package to 0.12.0 and let me know

lcd1232 commented 7 years ago

@pghilardi after updating and restarting I got this error

Click to expand[Enter steps to reproduce:] **Atom**: 1.16.0 x64 **Electron**: 1.3.13 **OS**: Mac OS X 10.12.4 **Thrown From**: [atom-python-virtualenv](https://github.com/pghilardi/atom-python-virtualenv) package 0.12.0 ### Stack Trace Failed to load the atom-python-virtualenv package ``` At Cannot read property 'replace' of undefined TypeError: Cannot read property 'replace' of undefined at VirtualenvManager.module.exports.VirtualenvManager.initEnvs (/packages/atom-python-virtualenv/lib/virtualenv-manager.coffee:40:46) at /packages/atom-python-virtualenv/lib/virtualenv-manager.coffee:18:8) at /packages/atom-python-virtualenv/lib/init.coffee:7:16) at /packages/atom-python-virtualenv/lib/init.coffee:1:1) at Module._compile (/app.asar/src/native-compile-cache.js:109:30) at /app.asar/src/compile-cache.js:216:21) at Module.load (module.js:473:32) at tryModuleLoad (module.js:432:12) at Function.Module._load (module.js:424:3) at Module.require (module.js:483:17) at require (/app.asar/src/native-compile-cache.js:50:27) at Package.module.exports.Package.requireMainModule (/app.asar/src/package.js:796:27) at /app.asar/src/package.js:123:28 at Package.module.exports.Package.measure (/app.asar/src/package.js:96:15) at Package.module.exports.Package.load (/app.asar/src/package.js:110:12) at PackageManager.module.exports.PackageManager.loadPackage (/app.asar/src/package-manager.js:468:14) at /app.asar/src/package-manager.js:412:19 at Config.module.exports.Config.transact (/app.asar/src/config.js:312:16) at PackageManager.module.exports.PackageManager.loadPackages (/app.asar/src/package-manager.js:407:19) at /app.asar/src/atom-environment.js:792:28 ``` ### Commands ``` ``` ### Non-Core Packages ``` atom-python-virtualenv 0.12.0 atom-typescript 11.0.3 autocomplete-python 1.8.63 busy-signal 1.4.1 Hydrogen 1.13.0 intentions 1.1.2 kite 0.23.0 language-nginx 0.7.3 linter 2.1.4 linter-flake8 2.2.1 linter-ui-default 1.2.4 ```

Also maybe this will be useful for you.

$ echo $WORKON_HOME
/Users/lcd1232/.virtualenvs

UPDATE. I added this lines in file virtualenv-manager.coffee after line 27

...
# Add home folder on search of virtualenvs
console.log process.env
console.log process.env.HOME
console.log process.env.WORKON_HOME
getVirtualEnvsFromHome = atom.config.get('atom-python-virtualenv.getVirtualEnvsFromHome')
...

And got this in console:

Object
/Users/lcd1232
undefined

Where Object has item WORKON_HOME:"/Users/lcd1232/.virtualenvs"

pghilardi commented 7 years ago

@lcd1232,

My mistake. Try the new version 0.13.0. To make it work with the WORKON_HOME you should customize it directly in the settings.

Let me know!

appukuttan-shailesh commented 7 years ago

@pghilardi : Great! That works for me :) ... Thanks for the quick fix.

lcd1232 commented 7 years ago

@pghilardi, Yes this works. Thanks a lot.

pghilardi commented 7 years ago

So I am closing this. Thanks!