WorldViz User Forum

WorldViz User Forum (
-   Vizard (
-   -   autocomplete for custom module? (

fivel_lab 02-01-2019 05:25 PM

autocomplete for custom module?
OK, so simple question but can't seem to find much help on the subject: is there a way to use the IDE's autocomplete for a custom module? The lab has a bunch of very commonly used utility functions and we have new people writing scripts every academic year. Would be very handy to be able to have autocomplete to facilitate training!

Jeff 02-03-2019 05:39 AM

After importing the module into your script, the autocomplete should display the function names. Is the module in the same folder as the script or a different location?

fivel_lab 02-04-2019 10:28 AM

Thanks! So, after your comment I confirmed that it works if the module is in the current directory of the script I'm working on. Very cool!

But, as you suspected, I have it setup as a package in a different directory (including I have added the path to the enclosing folder with sys.path.insert, but it still doesn't work.. ?

Jeff 02-05-2019 05:58 AM

Can you post the code you are using to import the file including any path related commands?

fivel_lab 02-06-2019 09:55 AM


Directory structure is set up like this:


FIVEL/                      top-level enclosing folder
          fvl/                        package
                        package initalization
                      example package module(s)
          VRproject/                        project directory
                              last semester's version of the exp
                            current semester's version

the code in ::::

import sys
import os
import os.path as path

sys.path.insert(0, path.dirname(path.dirname(path.dirname(__file__))))

#confirm path info with print statements
print path.dirname(__file__)
print path.dirname(path.dirname(__file__))
print path.dirname(path.dirname(path.dirname(__file__)))
print sys.path
print os.listdir(path.dirname(path.dirname(path.dirname(__file__))))

import fvl #no error

but.. after that no magic autocomplete :confused:


Jeff 02-15-2019 08:47 PM

It does not look like the autocomplete is set to work with paths added on the fly using the sys.path.insert command. It may work by adding to the PYTHONPATH environment variable.

If the module is in a directory above you could use the following code to import the module. I just tested and this worked for me with the autocomplete:


# import module in directory above
from .. import my_module

# import module two directories above
from ... import my_module

fivel_lab 02-17-2019 12:46 PM

The workaround worked for me too. Thanks for checking on that!

fivel_lab 02-18-2019 12:15 PM

oops just kidding.. the workaround code makes autocomplete work(ish) but throws an error on execution

ValueError: Attempted relative import in non-package

All times are GMT -7. The time now is 01:49 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Copyright 2002-2018 WorldViz LLC