Skip to content
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

Autocomplete not working for imported modules in venv #298

Closed
sh3lld00m opened this issue Mar 23, 2017 · 4 comments
Closed

Autocomplete not working for imported modules in venv #298

sh3lld00m opened this issue Mar 23, 2017 · 4 comments

Comments

@sh3lld00m
Copy link

Steps to Reproduce

  1. Create and enable Python 2.7 virtual environment using virtualenv: located in venv folder inside the project folder.
bqCodelab (venv)$ pwd
/Users/javiercm/Code/Projects/bqCodelab
bqCodelab (venv)$ tree -d -L 2
.
└── venv
    ├── bin
    ├── include
    └── lib
bqCodelab (venv)$ echo $VIRTUAL_ENV
/Users/javiercm/Code/Projects/bqCodelab/venv
bqCodelab (venv)$ which python
/Users/javiercm/Code/Projects/bqCodelab/venv/bin/pip2
bqCodelab (venv)$ which pip2
/Users/javiercm/Code/Projects/bqCodelab/venv/bin/pip2
  1. Install module using pip2:
bqCodelab (venv)$ pip2 install --upgrade google.cloud 
bqCodelab (venv)$ pip2 show google.cloud
Name: google-cloud
Version: 0.23.0
Summary: API Client library for Google Cloud
Home-page: https://github.com/GoogleCloudPlatform/google-cloud-python
Author: Google Cloud Platform
Author-email: jjg+google-cloud-python@google.com
License: Apache 2.0
Location: /Users/javiercm/Code/Projects/bqCodelab/venv/lib/python2.7/site-packages
Requires: google-cloud-storage, google-cloud-core, google-cloud-vision, google-cloud-translate, google-cloud-bigtable, google-cloud-pubsub, google-cloud-dns, google-cloud-error-reporting, google-cloud-speech, google-cloud-monitoring, google-cloud-resource-manager, google-cloud-datastore, google-cloud-spanner, google-cloud-language, google-cloud-logging, google-cloud-runtimeconfig, google-cloud-bigquery
  1. Open Atom from the project folder
bqCodelab (venv)$ atom .

Expected behavior:
To get autocompletion and access to google.cloud module classes and submodules inside Atom.

Actual behavior:
Autocomplete does work for standard Python modules, but it does not detect the previously installed module:
screen shot 2017-03-23 at 9 38 33 am
nor it does autocompletes once the module has been imported:
screen shot 2017-03-23 at 11 10 38 am

The extension does not throw any error in Developers console. I've also tried adding both Python Executable Paths (/Users/javiercm/Code/Projects/bqCodelab/venv/bin/python) and Extra Paths for Packages (/Users/javiercm/Code/Projects/bqCodelab/venv/lib/python2.7/site-packages) without success.

@sh3lld00m sh3lld00m changed the title Autocomplete not working for Autocomplete not working for imported modules in venv Mar 23, 2017
@sadovnychyi
Copy link
Member

I'm pretty sure it's going to work for most of modules installed in venv with google cloud as an exception.

I did try to install it with this steps:

  1. cd my/project && env/bin/pip install google.cloud
  2. Try from google. completions – I'm only seeing my app engine related completions – removing /usr/local/google_appengine from Extra Paths For Packages helps to eliminate them.
  3. Still cannot see google.cloud module – by going into env/lib/python2.7/site-packages/google I can see that there's no __init__.py file presented in both root and cloud sub-package. I've created them and now I can see them in Atom.

image

So, I see no issues with this package. I'm sure other modules are going to work for you.
I cannot answer why __init__.py files are not there and how is it possible to work without them at all. The whole google package seems super confusing for me especially if you use app engine standard environment – in this case it seems it's not possible to use them together at all.

@sh3lld00m
Copy link
Author

Looks the reason why the package has no __init__.py is because the package creators switched to Namespace Packages: see Missing init.py #2767 in GitHub. I guess packages following it should have the same issue.

I've seen PyCharm CE is performing autocompletion for this package, but I've got no idea how they do it without the __init__.py file.

@sadovnychyi
Copy link
Member

Possibly worth to fill a bug in Jedi.

https://github.com/davidhalter/jedi

@sadovnychyi
Copy link
Member

davidhalter/jedi#122

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants