1

Consider the following directory structure:

lib/ markov.py solver.py test.py 

markov.py has the following code: super() throwing an error in Sublime Text, works in PyCharm/Terminal

solver.py only contains a bunch of mathematical functions, here's an example of one:

def mm1_busy_idle(arrival, service): return round(1 - (arrival / service), 4) 

Now, when I try to do import solver in markov.py, PyCharm tells me that there's No module named solver. However, when I do import test it does it just well and I can run the test function from there:

def test(): print("test!") 

Also, when I hover over test.test() PyCharm shows me the following tooltip: Cannot find reference 'test' in '__init__.py'.

My question is: Why can I import test and run the function test() but I can't import solver in markov.py?

4
  • try from . import solver Commented Mar 16, 2017 at 0:09
  • @yosemite_k SystemError: Parent module '' not loaded, cannot perform relative import Commented Mar 16, 2017 at 0:11
  • from lib import solver Commented Mar 16, 2017 at 0:18
  • @yosemite_k That gives me unresolved reference Commented Mar 16, 2017 at 0:23

1 Answer 1

2

add one file (__init__.py empty file) in lib,

lib/ __init__.py markov.py solver.py test.py 

An ultimate solution:

import sys sys.path.append("/path/to/lib") 
Sign up to request clarification or add additional context in comments.

1 Comment

Your proposed solution didn't really change much.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.