Python Forum
Import error with local file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Import error with local file
#1
Smile 
Hello. When I try to run a python file
python optimizer.py
it says
ImportError: No module named optimizers.PSO
There is a file called "PSO.py" on the folder "optimizers", that happens to be on the same directory where "optimizer.py" it is:

So, it is all about showing python this PSO.py? If yes, how can I do that? Many thanks
Reply
#2
Try python -m optimizers.optimizer perhaps.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to write variable in a python file then import it in another python file? tatahuft 4 872 Jan-01-2025, 12:18 AM
Last Post: Skaperen
  import a function from another file using relative path paul18fr 6 2,722 Aug-01-2024, 06:40 AM
Last Post: paul18fr
Bug Python 3.12 cannot import local python files as modules sunflowerdog 25 17,414 Jul-31-2024, 01:52 PM
Last Post: sunflowerdog
  Error on import: SyntaxError: source code string cannot contain null bytes kirkwilliams2049 7 19,349 Aug-03-2023, 06:00 PM
Last Post: Gribouillis
Video doing data treatment on a file import-parsing a variable EmBeck87 15 5,524 Apr-17-2023, 06:54 PM
Last Post: EmBeck87
  Import XML file directly into Excel spreadsheet demdej 0 1,566 Jan-24-2023, 02:48 PM
Last Post: demdej
  import module error tantony 5 4,876 Dec-15-2022, 01:55 PM
Last Post: Lauraburmrs
  Cryptic Error with import statement Led_Zeppelin 2 3,546 Jan-11-2022, 01:13 PM
Last Post: Led_Zeppelin
  Install any library via pip get an error cannot import name 'SCHEME_KEYS' from 'pip. Anldra12 2 12,950 Jan-04-2022, 01:05 PM
Last Post: Anldra12
  How from sklearn.datasets import load_diabetes change to import to CSV file Anldra12 0 2,660 Dec-25-2021, 07:20 PM
Last Post: Anldra12

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020