0

I’m working on a Jupyter notebook, and am getting an error with this:

First, I import a variable from a module:

from data_generation.names import headers

which gives me no problem at all. Then a few cells below I try to make another import from the same module:

from data_generation.names import alldata_path

which gives me this error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-90-2663c91db1e3> in <module>
      1 from data_generation.data_preprocessing import data_to_csv
----> 2 from data_generation.names import alldata_path

ImportError: cannot import name 'alldata_path'

i got this 2 variables in the file|module names.py, who looks like this:

headers = {"V": ["FECHA", "MEDICION (V)"], "T":["FECHA", "MEDICION (T)"], "A":["FECHA", "MEDICION (A)"]}

alldata_path = ("C:/Users/Bastolo/Desktop/aritech/argomedo-solar-maintenance/data/all_data/")

I would appreciate any help on how to properly do this, since I want to keep a list (not list type) of variables if posible instead of using a dictionary to map all the variables I pretend to use.

EDIT: im getting this error just on the notebook, in IPython works fine... though id like to have it workin on the notebook

1
  • Welcome to StackOverflow! When posting, try to proofread your messages for typos :). Commented Dec 22, 2018 at 22:42

1 Answer 1

1

Are you looking for this?

from module import a, b, c

Note that if you want to import everything you can just do

from module import *

Or import the module and access them with full path:

import module
module.a()
Sign up to request clarification or add additional context in comments.

2 Comments

Maybe, the thing is im trying to make a distinction in the order of appearence of the variables, thinking of a proper way to document the code usage. Lets say im actually doing this: to make this thing happen (in the first cell) we need to import this variable. Then i make some other data management, and a few cells below i do: now for this thing to happen we need to import this another variable.
Side note: Please don't use from module import *. If you import multiple modules, you (or anyone who later works on your code) will have no idea which module things came from, and there might even be namespace conflicts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.