1

I'm struggling to handle my paths for the project. To give you an overview I need to show you my directory tree:

enter image description here

I'd like to setup the paths correctly so that I won't have to change them when working on two machines.

In PortfolioOptimizer notebook, I'm using:

# set current working path
notebook_path = os.getcwd()
print (notebook_path)

I don't understand, why it prints out C:\xampp\htdocs\tools\python\learn2fly which is the path to the different project.

Even when I add let's say portfolio_paths.py to Portfolio_analysis directory with this code:

import os


def get_dir_path():
    current_path = os.getcwd()
    return current_path

and then in my notebook I use the below line of code:

from Portfolio_analysis.portfolio_paths import get_dir_path
 # set current working path
notebook_path = get_dir_path()

I'm still getting C:\xampp\htdocs\tools\python\learn2fly

krakowi
  • 531
  • 4
  • 14

1 Answers1

0

getcwd() returns the current working directory, this may change based on the way you run Jupyter Notebook or Lab (namely if you use --notebook-dir).

Take also a look to this answer.

Pierluigi
  • 628
  • 1
  • 5
  • 14