I’m trying to connect to Traci-Server within my Conda environment (Conda is needed for my Tensorflow project) that I intend to interface with SUMO Traffic Simulator
import os, sys
if 'SUMO_HOME' in os.environ:
tools = os.path.join(os.environ['SUMO_HOME'], 'tools')
sys.path.append(tools)
else:
sys.exit("please declare environment variable 'SUMO_HOME'")
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
import traci #TraCI functionality
from sumolib import checkBinary #checkBinary help locate the Sumo binaries
import time
traci.connect()
traci.start(['sumo-gui', '-c', 'osm.sumocfg', "--start", "--quit-on-end"])
traci.close()
However, I’m getting Connection errors
C:\Users\<UserName>\.conda\envs\tf\python.exe "C:/Users/<UserName>/PycharmProjects/Tensor Tutorial/TestTraffic.py"
Retrying in 1 seconds
Could not connect to TraCI Server at localhost:8813 [WinError 10061] No connection could be made because the target machines actively refused it
Retrying in 1 seconds
Could not connect to TraCI Server at localhost:8813 [WinError 10061] No connection could be made because the target machines actively refused it
Retrying in 1 seconds
Could not connect to TraCI Server at localhost:8813 [WinError 10061] No connection could be made because the target machines actively refused it
Retrying in 1 seconds
Traceback (most recent call last):
File "C:\Program_Files_(x86)\Eclipse\Sumo\tools\traci\main.py", line 166, in connect
conn = Connection(host, port, proc)
File "C:\Program_Files_(x86)\Eclipse\Sumo\tools\traci\main.py", line 51, in __init__
self._socket.connect((host, port))
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/<UserName>/PycharmProjects/Tensor Tutorial/TestTraffic.py", line 24, in <module>
traci.connect()
File "C:\Program_Files_(x86)\Eclipse\Sumo\tools\traci\main.py", line 127, in connect
time.sleep(waitBetweenRetries)
KeyboardInterrupt
Process finished with exit code 1
CodePudding user response:
Just leave out the traci.connect. It is not needed if you use traci.start.