Good day,
I'm having a problem i can't really explain. The error i get is "filenofounderror" to my understanding of python. you can get this error while using open() and when using relative path to a file that is not in the same directory of the programme.
I'm an absolute beginner in programming and here's my code snippet below:
from subprocess import run, PIPEdef fun(): venv = run(("python", "-m", "venv", "env"), stdout=PIPE, stderror=PIPE) if venv.returncode == 0: activate = run(("source", "env/bin/activate"), stdout=PIPE, stderror=PIPE) if activate.returncode == 0: print("Virtual Environment created and activated!") else: print(activate.stderror) else: print(venv.stderror)fun()
The idea around this is to create a setup file for a project that i'm working on and create all the database in place and create a development virtual environment with python during the setup phase.
In doing so i get the following error:
Traceback (most recent call last): File "/home/sihle/Documents/Development/python/NewPass/setup.py", line 105, in <module> venvf() File "/home/sihle/Documents/Development/python/NewPass/setup.py", line 23, in venvf run(("source", "loco/bin/activate"), stdout=PIPE, stderr=PIPE) File "/usr/lib/python3.11/subprocess.py", line 548, in run with Popen(*popenargs, **kwargs) as process: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/lib/python3.11/subprocess.py", line 1950, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename)FileNotFoundError: [Errno 2] No such file or directory: 'source'
I have tried to run with os.system(). Although is works, it does not meet my internded use as i cannot or won't now if the returncode is 0 or the command is success or failed.