title: create a python module which is understood by jupyter notebook from inside a conda environment
body: <p>I have installed anaconda and using conda I created an environment. All packages except zenlog which was installed using pip inside the env, were installed using conda.</p>
  
  <p>I have two modules (.py files) written the following way both of which have the error I describe below. </p>
  
  <p>The modules are stored in the /Documents/python/project directory along with the environment file I used to create and activate this environment.</p>
  
  <p>All libraries or packages are visible using <code>conda list</code> and import correctly. It's just my simple module that fails when I try to create an object of the <code>logtextfile</code> class.</p>
  
  <p>when I create an object from my logging module (which I call mylog.py) I get the error: `</p>
  
  <blockquote>
    <p>NameError: name 'logtextfile' is not defined</p>
  </blockquote>
  
  <p>This error occurs when I create a jupyter notebook in the same directory as my mylog.py module and import it as follows:</p>
  
  <pre><code>import mylog  # A simple module to log a message to a text file.
  </code></pre>
  
  <p>But when I copy the class and functions of the mylog module into a cell of the testing.ipynb jupyter notebook and create an object of the class it works without a problem.</p>
  
  <hr>
  
  <p><strong>What do I have to do differently when creating an object of the logging class when it's in a module (a separate .py file) as compared to a jupyter notebook cell?</strong></p>
  
  <hr>
  
  <p><strong>The file structure of my project folder is:</strong></p>
  
  <p>Folder: /Documents/python/project directory</p>
  
  <p>File testing.ipynb</p>
  
  <p>File mylog.py</p>
  
  <p>..</p>
  
  <p><strong>My module is:</strong></p>
  
  <pre><code>import datetime
  import os
  
  class logtextfile(object):   
      def __init__(self, name):
          self.name = name
  
      def __str__(self):
          return "{} ".format(self.__class__.__name__)
  
      def write(self,**kwargs):
          """Writes a log message to a user specified file which indicates the action takes and if it was successful"""
          self.file = kwargs.get('file',"log.txt")
          self.loglevel = kwargs.get('loglevel',"critical")
          self.logmessage = kwargs.get('logmessage',"error")
          self.success = kwargs.get('success',False)
          self.class_name = kwargs.get('class',str("{}".format(self.__class__.__name__)))
          self.output = ", ".join([str(datetime.datetime.now().replace(second=0,microsecond=0)),self.class_name,str(self.logmessage),str(self.success),str("\n")])
  
          for key, value in kwargs.items():
              setattr(self,key,value)
  
          f = open(str(self.file),"a")
          f.write(self.output)
          f.close()
  
      def now(self, filename, openas, data):
          """Creates a log file with todays date and time"""
          fmt='%Y-%m-%d-%H-%M-%S_{fname}'
          fn = datetime.datetime.now().strftime(fmt).format(fname=filename)
          f = open(str(fn),openas)
          f.write(data + "\n")
          f.close()
  </code></pre>
  
  <p><strong>Here is a copy of my conda environment</strong> 
  If anyone wants to try creating an object of the logging class inside a jupyter notebook cell and by importing it from my mylog.py file.</p>
  
  <p>Requirements:</p>
  
  <ul>
  <li>Anaconda installed</li>
  <li>Create environment from file</li>
  </ul>
  
  <pre class="lang-html prettyprint-override"><code>&lt;pre&gt;
    &lt;code&gt;
  name: stocks_library
  channels:
  - anaconda-fusion
  - defaults
  dependencies:
  - appnope=0.1.0=py35_0
  - beautifulsoup4=4.5.3=py35_0
  - blaze=0.10.1=py35_0
  - bleach=1.5.0=py35_0
  - bokeh=0.12.5=py35_0
  - chest=0.2.3=py35_0
  - click=6.7=py35_0
  - cloudpickle=0.2.2=py35_0
  - cytoolz=0.8.2=py35_0
  - dask=0.13.0=py35_0
  - datashape=0.5.4=py35_0
  - decorator=4.0.11=py35_0
  - entrypoints=0.2.2=py35_1
  - flask=0.12.1=py35_0
  - flask-cors=3.0.2=py35_0
  - h5py=2.6.0=np110py35_0
  - hdf5=1.8.15.1=2
  - heapdict=1.0.0=py35_1
  - html5lib=0.999=py35_0
  - icu=54.1=0
  - ipykernel=4.6.1=py35_0
  - ipython=6.0.0=py35_0
  - ipython_genutils=0.2.0=py35_0
  - ipywidgets=6.0.0=py35_0
  - itsdangerous=0.24=py35_0
  - jinja2=2.9.6=py35_0
  - jsonschema=2.6.0=py35_0
  - jupyter=1.0.0=py35_3
  - jupyter_client=5.0.1=py35_0
  - jupyter_console=5.1.0=py35_0
  - jupyter_core=4.3.0=py35_0
  - libiconv=1.14=0
  - libpq=9.5.4=0
  - libxml2=2.9.4=0
  - libxslt=1.1.29=0
  - llvmlite=0.11.0=py35_0
  - locket=0.2.0=py35_1
  - lxml=3.7.3=py35_0
  - markupsafe=0.23=py35_2
  - mistune=0.7.4=py35_0
  - mkl=11.1=np110py35_p1
  - mkl-rt=11.1=p0
  - mkl-service=1.1.0=py35_p0
  - multipledispatch=0.4.9=py35_0
  - mysql-connector-python=2.0.4=py35_0
  - nbconvert=5.1.1=py35_0
  - nbformat=4.3.0=py35_0
  - networkx=1.11=py35_0
  - notebook=5.0.0=py35_0
  - numba=0.26.0=np110py35_0
  - numexpr=2.4.6=np110py35_0
  - numpy=1.10.2=py35_p0
  - odo=0.5.0=py35_1
  - openssl=1.0.2k=1
  - pandas=0.18.1=np110py35_0
  - pandas-datareader=0.2.1=py35_0
  - pandasql=0.7.3=py35_0
  - pandocfilters=1.4.1=py35_0
  - partd=0.3.7=py35_0
  - path.py=10.3.1=py35_0
  - pexpect=4.2.1=py35_0
  - pickleshare=0.7.4=py35_0
  - pip=9.0.1=py35_1
  - postgresql=9.5.4=0
  - prompt_toolkit=1.0.14=py35_0
  - psutil=5.2.2=py35_0
  - psycopg2=2.7.1=py35_0
  - ptyprocess=0.5.1=py35_0
  - pygments=2.2.0=py35_0
  - pymysql=0.7.9=py35_0
  - pyqt=5.6.0=py35_2
  - pytables=3.2.2=np110py35_0
  - python=3.5.3=1
  - python-dateutil=2.6.0=py35_0
  - pytz=2017.2=py35_0
  - pyyaml=3.12=py35_0
  - pyzmq=16.0.2=py35_0
  - qt=5.6.2=0
  - qtconsole=4.3.0=py35_0
  - readline=6.2=2
  - requests=2.13.0=py35_0
  - requests-file=1.4.1=py35_0
  - scikit-learn=0.17=np110py35_p1
  - scipy=0.16.1=np110py35_p0
  - setuptools=27.2.0=py35_0
  - simplegeneric=0.8.1=py35_1
  - sip=4.18=py35_0
  - six=1.10.0=py35_0
  - sqlalchemy=1.1.9=py35_0
  - sqlite=3.13.0=0
  - terminado=0.6=py35_0
  - testpath=0.3=py35_0
  - tk=8.5.18=0
  - toolz=0.8.2=py35_0
  - tornado=4.4.2=py35_0
  - traitlets=4.3.2=py35_0
  - wcwidth=0.1.7=py35_0
  - werkzeug=0.12.1=py35_0
  - wheel=0.29.0=py35_0
  - widgetsnbextension=2.0.0=py35_0
  - xz=5.2.2=1
  - yaml=0.1.6=0
  - zlib=1.2.8=3
  - pip:
    - ipython-genutils==0.2.0
    - jupyter-client==5.0.1
    - jupyter-console==5.1.0
    - jupyter-core==4.3.0
    - prompt-toolkit==1.0.14
    - tables==3.2.2
  prefix: /Users/joshua/miniconda3/envs/stocks_library
    &lt;/code&gt;
  &lt;/pre&gt;
  </code></pre>