0

I have a project folder:

project
├── notebooks
│   └── EDA.ipynb
├── setup.py
└── src
    ├── data
    │   ├── make_data.py
    │   └── __init__.py
    └── __init__.py

The content in setup.py is:

from setuptools import find_packages, setup

setup(
    name='src',
    packages=find_packages(),
    version='0.1.0',
    description='',
    author='AG',
    license='MIT')

After using pip install . from project\ to make my src a python module I can see the module src when I make conda list... But when I try to import some function from make_data.py when I am working in EDA.ipynb:

from src.data.make_data import some_func

I get:

ModuleNotFoundError: No module named 'src'

What am I doing wrong?

2 Answers 2

1

Is the virtual environment where you installed 'src' same, where you are trying this.

Pls. run the

pip list

in that virtual environment to check if 'src' is installed.

Also, pls. check the import statement in the python interpreter of your virtual env.

1
  • When I run pip list I can see also the src package in the environment. And when I import src from python interpreter it loads successfully... In the other attempts from the EDA.ipynb I was also in the correct environmnet.
    – Slevin_42
    Oct 8, 2020 at 13:48
0

I have managed to solve the problem, thanks to @Simplecode for the help. It seems that from the terminal I was able to import the module but not from spyder or jupyterlab, despite I was in the same virtual environment. This was because the IDLE were using a different version of python, since they were not installed in the virtualenv. Installing spyder and jupyterlab within the environment solved the import problem.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.