Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
file directory
#1
newbie here - please be gentle :)

Having a path error when trying to run a file in the terminal

Path:
/Users/linardsberzins/Desktop/weatherterm/weatherterm/core/unit.py

Error:
No such file or directory

command:
python ~/Users/linardsberzins/Desktop/weatherterm/weatherterm/core/unit.py

Any advice appreciated

[Image: GQFc0Rw]

thanks
Reply
#2
have you tried:
from command window:
cd /Users/linardsberzins/Desktop/weatherterm/weatherterm/core/
# if that works:
python /Users/linardsberzins/Desktop/weatherterm/weatherterm/core/unit.py
also, make sure letter case is correct
Reply
#3
you seem to be missing some files from the github project: image

be sure to install both requirements
pip install -r requirements.txt
pip install -r requirements_dev.txt

and then try to test it with
python -m weatherterm -u Fahrenheit -a SWXX2372:1:SW -p WeatherComParser -td
Reply
#4
Thank you @Cryptus

I just added the first class call in unit.py not that far yet :)

Will try @Larz60+ approach now.

Thank you for help

@Larz60+ and @Cryptus

file contents:
unit.py
from enum import auto, unique
from .base_enum import EBasenum

@unique
class Unit(BaseEnun):
    CELSIUS = auto()
    FAHRENHEIT = auto()
base_enum.py
from enum import Enum

class BaseEnum(Enum):
    def _generate_next_value_(self, name, start, count, last_value):
        return name
parser_loader.py
import os
import re
import inspect

def _get_parser_list(dirname):
    files = [f.replace('.py', '')
             for f in os.listdir(dirname)
             if not f.startswitch('__')]
    return files

def _import_parsers(parserfiles):
    m = re.compile('.+parsers$', re.I)
    _modules = __import__('weatherterm.parsers',
                          globals(),
                          locals(),
                          parserfiles,
                          0)
    _parsers = [(k, v) for k, v in inspect.getmembers(_modules)
                if inspect.ismodule(v) and m.match(k)]
    _classes = dict()
    
    for k, v in _parsers:
        _classes.update({k: v for k, v in inspect.getmembers(v)
                         if inspect.isclass(v) and m.match(k)})
        return _classes
    
    def load(dirname):
        parserfiles = _get_parser_list(dirname)
        return _import_parsers(parserfiles)
Error:
File "/Users/linardsberzins/Desktop/weatherterm/weatherterm/core/unit.py", line 2, in <module>
    from .base_enum import EBasenum
ImportError: attempted relative import with no known parent package
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Using pyinstaller with .ui GUI files - No such file or directory error diver999 3 3,079 Jun-27-2023, 01:17 PM
Last Post: diver999
  Extract file only (without a directory it is in) from ZIPIP tester_V 1 928 Jan-23-2023, 04:56 AM
Last Post: deanhystad
Thumbs Up Need to compare the Excel file name with a directory text file. veeran1991 1 1,065 Dec-15-2022, 04:32 PM
Last Post: Larz60+
  no such file or directory in SFTP saisankalpj 2 1,493 Nov-25-2022, 11:07 AM
Last Post: DeaD_EyE
Photo Making Zip file of a file and Directory Nasir 2 985 Oct-07-2022, 02:01 PM
Last Post: Nasir
  Failed to execute child process (No such file or directory) uriel 1 1,616 Sep-15-2022, 03:48 PM
Last Post: Gribouillis
  Need Help: FileNotFoundError:[Errno 2] No such file or directory python202209 5 2,524 Sep-12-2022, 04:50 AM
Last Post: python202209
  importing functions from a separate python file in a separate directory Scordomaniac 3 1,330 May-17-2022, 07:49 AM
Last Post: Pedroski55
  How to read python shortcut target profile directory of Chrome Ink file sunny9495 1 1,617 Apr-12-2022, 06:12 PM
Last Post: sunny9495
Question Help to find the largest int number in a file directory SalzmannNicholas 1 1,586 Jan-13-2022, 05:22 PM
Last Post: ndc85430

Forum Jump:

User Panel Messages

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