Can't import library on python 3.7
See original GitHub issueHi, using Python 3.7, I can’t use the pathfinding module.
I’ve tried in an virtualenv and by installing it directly in the system packages.
Error is:
python.exe pathfinding.py
Traceback (most recent call last):
File "pathfinding.py", line 1, in <module>
from pathfinding.core.diagonal_movement import DiagonalMovement
File "pathfinding.py", line 1, in <module>
from pathfinding.core.diagonal_movement import DiagonalMovement
ModuleNotFoundError: No module named 'pathfinding.core'; 'pathfinding' is not a package
Process finished with exit code 1
Sample code used:
from pathfinding.core.diagonal_movement import DiagonalMovement
from pathfinding.finder.a_star import AStarFinder
from pathfinding.core.grid import Grid
matrix = [
[1, 1, 1],
[1, 0, 1],
[1, 1, 1]
]
grid = Grid(matrix=matrix)
start = grid.node(0, 0)
end = grid.node(2, 2)
finder = AStarFinder(diagonal_movement=DiagonalMovement.always)
path, runs = finder.find_path(start, end, grid)
print('operations:', runs, 'path length:', len(path))
print(grid.grid_str(path=path, start=start, end=end))
Any idea how to make it work?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
python 3.7 can't import modules - Stack Overflow
From my personal experience(with other modules), uninstalling the module using pip uninstall selenium and reinstalling it using pip install ...
Read more >Why Can't Python Find My Modules? - Real Python
A common error that new Pythonistas will come across is that the packages they think they've installed are not actually being recognized by ......
Read more >Cannot import Python Libraries anywhere - Super User
I am on MacOS 10.14.5. I currently cannot import any Python third-party Library from anywhere (including VSCode, Pycharm and terminal). Detail.
Read more >5. The import system — Python 3.11.1 documentation
When a module is first imported, Python searches for the module and if found, it creates a module object 1, initializing it. If...
Read more >Resolve "Unable to import module" errors from Python ...
You typically receive this error when your Lambda environment can't find the specified library in the Python code. This is because Lambda ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah, I should have seen this earlier in your first post, your file is named pathfinding.py! Just rename it to something else! (e.g. path_finding.py) and you should be fine 😄
Thank you so much. You have resolve our problem.