Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WinError 3] The system cannot find the path specified #42

Open
scottzach1 opened this issue Mar 10, 2022 · 3 comments
Open

[WinError 3] The system cannot find the path specified #42

scottzach1 opened this issue Mar 10, 2022 · 3 comments

Comments

@scottzach1
Copy link

The example in tests fails to run throwing a path error.

System Details:

  • Windows 10
  • Python 3.9 (venv)
  • Installed version: 0.5.0

The example in tests fails to run with the following error:

from treeplotter.tree import Node, Tree, create_tree_diagram
root = Node(value=1.0, name=None)

child1 = Node(value=0.5, name=None)
child2 = Node(value=1.0, name=None)
child3 = Node(value=3.0, name="A")
root.children = {child1, child2, child3}
root.children

granchild1 = Node(value=0.5, name=None)
granchild2 = Node(value=3.0, name="B")
granchild3 = Node(value=2.0, name="C")
greatgrandchild = Node(value=1.0, name="D")

child1.add_children([granchild1, granchild2])
child2.add_child(granchild3)
granchild1.add_child(greatgrandchild)


tree = Tree(root=root)

create_tree_diagram(
    tree=tree,
    save_path='/Users/{{USER}}/Downloads',  # also fails with `r"C:\\Users\{{USER}}\Downloads"`
    webshot=True,
    verbose=True
)

Output (obfuscated):

-> Creating directory and writing tree to JSON...
-> Copying templates...
Traceback (most recent call last):
  File "C:\Users\{{USER}}\PycharmProjects\{{PROJECT_NAME}}\main.py", line 42, in <module>
    create_tree_diagram(
  File "C:\Users\{{USER}}\PycharmProjects\{{PROJECT_NAME}}\venv\lib\site-packages\treeplotter\plotter.py", line 180, in create_tree_diagram
    _prepare_docs_and_screenshot(
  File "C:\Users\{{USER}}\PycharmProjects\{{PROJECT_NAME}}\venv\lib\site-packages\treeplotter\plotter.py", line 99, in _prepare_docs_and_screenshot
    for this_file in os.listdir(treant_templates):
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\{{USER}}\\PycharmProjects\\{{PROJECT_NAME}}\\venv\\lib\\site-packages\\treeplotter/templates'

Pip Freeze

click==8.0.4
colorama==0.4.4   
Jinja2==3.0.3     
jsonpickle==2.1.0 
MarkupSafe==2.1.0 
treeplotter==0.5.0
Wand==0.6.7
@Luke-Poeppel
Copy link
Owner

Thanks for filing this issue, @scottzach1! Pretty sure I know what the problem is. Unfortunately I'm quite busy these days (I'm in my last year of university) and I haven't had much time to work on this project, but I'll get to it as soon as I can! 👍

@Luke-Poeppel
Copy link
Owner

Luke-Poeppel commented Mar 10, 2022

If you'd like to fix it yourself and submit a pull request, I think it should be as simple as changing the second line here:

here = os.path.abspath(os.path.dirname(__file__))
treant_templates = here + "/templates"

to the following:

treant_templates = os.path.join(here, "templates")

The current line assumes the Mac file path system, and is therefore inconsistent when being appended to a Windows filepath. Very good catch!

@ishandutta2007
Copy link

ishandutta2007 commented Mar 17, 2022

I am getting similar error but the error is not though by python , It is coming from js I think.



>>> create_tree_diagram(tree=tree, save_path=mypath, webshot=True, verbose=True)
-> Creating directory and writing tree to JSON...
-> Copying templates...
-> Writing index.html...
-> Writing Treant CSS file...
-> Writing Node CSS file...
-> Running browserify...
-> Creating webshot with R...
The system cannot find the path specified.
Done ✔
'C://Users//hp//Documents//Projects//spx'
>>>

I have tried all possible ways of writing path:

mypath="C:\\Users\\hp\\Documents\\Projects\\spx"

or

mypath="C:/Users/hp/Documents/Projects/spx"

or

mypath="C://Users//hp//Documents//Projects//spx"

PS:
I am on Windows 10 and Python 3.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants