[nengo-user] Importing User-Defined Modules

Brian Krainer bkrainer731 at gmail.com
Mon Jul 21 15:12:11 EDT 2014


import nef
import nps
from ca.nengo.math.impl import ConstantFunction
import math
import random
import sys
sys.path.append(path_to_functions.py)
import functions.py


On Mon, Jul 21, 2014 at 3:11 PM, Xuan Choo <fchoo at cs.uwaterloo.ca> wrote:

> Hi Brian,
>
> Can you copy & paste the top bit of your code -- the part with all the
> import statements (you can censor the filepaths if you wish) into the email
> chain?
>
> Cheers,
>
>
> -------------------------
> Xuan Choo
> PhD Candidate
> Computational Neuroscience Research Group
> Centre for Theoretical Neuroscience, University of Waterloo
> Tel: (519) 888 4567 ext: 38842
> HP: (226) 339 3892
> Office: PAS 2462
>
>
> On Mon, Jul 21, 2014 at 3:01 PM, Brian Krainer <bkrainer731 at gmail.com>
> wrote:
>
>> I have a file called 'functions.py' which I am trying to import. At the
>> top of the script with the network I included 'import functions' but I'm
>> getting the error "ImportErro: No Module named functions" when I try to
>> open the script in the nengo workspace. I did what Xuan suggested with
>> sys.path.append, but I still get the same error. Any ideas?
>>
>> brian
>>
>>
>> On Mon, Jul 21, 2014 at 2:46 PM, Daniel Rasmussen <dhrsmss at gmail.com>
>> wrote:
>>
>>> Hi Brian,
>>>
>>> What difficulty are you having when importing the file?  Could you post
>>> the error message?  A Nengo script is just a regular Python file, so
>>> importing should work the same as anywhere else in Python.  One thing to
>>> remember is that in Nengo 1.4 everything is running through Jython, so you
>>> need to make sure that the module you're importing is Jython compatible.
>>>
>>> Daniel
>>>
>>>
>>> On 21 July 2014 13:51, Brian Krainer <bkrainer731 at gmail.com> wrote:
>>>
>>>> Hello,
>>>>
>>>> As I'm sure you know, Python allows users to import other .py files and
>>>> use functions from those imported files. Is there any way to import my own
>>>> files in the .py file with the Nengo network? I've been trying to do this
>>>> but I've been having some difficulties.
>>>>
>>>> Thanks,
>>>>
>>>> Brian
>>>>
>>>> _______________________________________________
>>>> nengo-user mailing list
>>>> nengo-user at ctnsrv.uwaterloo.ca
>>>> http://ctnsrv.uwaterloo.ca/mailman/listinfo/nengo-user
>>>>
>>>>
>>>
>>
>> _______________________________________________
>> nengo-user mailing list
>> nengo-user at ctnsrv.uwaterloo.ca
>> http://ctnsrv.uwaterloo.ca/mailman/listinfo/nengo-user
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://artsservices.uwaterloo.ca/pipermail/nengo-user/attachments/20140721/bf87949b/attachment-0002.html>


More information about the nengo-user mailing list