Ошибка execvp (3). Нет такого файла или каталога. Состояние завершено через 0,031 секунды. - ATOM - Script Runner (плагин) - PullRequest
0 голосов
/ 09 ноября 2018

Здравствуйте, у меня проблема с ATOM при программировании на python. Я использую macos Mojave (последнее обновление). У меня никогда не было проблем, но сегодня с этим кодом моего профессора я получаю ошибку, которую вы видите в названии. Я всегда использую (#! / Usr / bin / python3) с любым моим кодом, чтобы он работал на Atom, в противном случае он будет работать на python2, чего я не хочу.

Я установил Simpy, как с pip, так и с pip3. Я установил runstats (необходимо запустить часть кода)

Я думаю, что проблема в пути. Я не знаю, как установить его для Atom, особенно для моего плагина "script-runner".

Код работает с терминалом, совсем не проблема.

Есть ли что-то, что я должен сделать с оболочкой или что-то еще? Я не эксперт, поэтому я действительно в отчаянии, потому что мне нужно это исправить.

(Также с другими редакторами, такими как Sublime, у меня была такая же проблема).

Я поставил здесь свой код:

#!/usr/bin/python3
import simpy
import numpy as np
import random
import matplotlib.pyplot as plt
from runstats import Statistics

# *******************************************************************************
# Constants
# *******************************************************************************
RANDOM_SEED = 42
NUM_SERVERS = 1
SIM_TIME = 1000

# *******************************************************************************
# Arrival process
# *******************************************************************************


def arrival(environment, arrival_rate):

    # keep track of client number
    i = 0

    # arrival will continue forever
    while True:  # infinite generator, but not infinite loop because we have the yield inside
        # the loop is just creating the client, then the process "client" intervenes
        # sample the time to next arrival
        inter_arrival = random.expovariate(lambd=arrival_rate)

        # yield an event to the simulator
        yield environment.timeout(inter_arrival)

        # a new client arrived
        i += 1
        Client(environment, i)

# *******************************************************************************
# Client
# *******************************************************************************


class Client(object):

    def __init__(self, environment, i):
        self.env = environment
        self.number = i

        # the client is a "process"
        env.process(self.run())

    def run(self):
        # store the absolute arrival time
        time_arrival = self.env.now
        #print("client", self.number, "has arrived at", time_arrival)

        # The client goes to the first server to be served
        # go to the server and stay there until you're done
        yield env.process(env.servers.serve())

        # calculate the response time
        #print("client", self.number, "response time", self.env.now - time_arrival)
        stats.push(self.env.now - time_arrival)


# *******************************************************************************
# Servers
# *******************************************************************************
class Servers(object):

    # constructor
    def __init__(self, environment, num_servers, service_rate):
        self.env = environment
        self.service_rate = service_rate
        self.servers = simpy.Resource(env, num_servers)

    def serve(self):
        # request a server
        # create an object that will be destroyed at the end, the object exists only in the "with"
        with self.servers.request() as request:
            yield request

            # server is free, wait until service is finished
            service_time = random.expovariate(lambd=self.service_rate)

            # yield an event to the simulator
            yield self.env.timeout(service_time)


# *******************************************************************************
# main
# *******************************************************************************
if __name__ == '__main__':

    mean_rt = np.zeros((10, 1))
    random.seed(RANDOM_SEED)
    for it in range(1, 10):
        mu = 2.0  # service time (2 events per unit of time)
        # arrival time (1 event per unit of time)
        lambd = it
    # *********************************
    # setup and perform the simulation
    # *********************************
        print('Simulation with lambda equal to ', lambd)
        stats = Statistics()
        env = simpy.Environment()

    # servers
        # controlling the servers (class servers)
        env.servers = Servers(env, NUM_SERVERS, mu)

    # start the arrival process
        env.process(arrival(env, lambd))

    # simulate until SIM_TIME
        env.run(until=SIM_TIME)
        # mean=Statistics.mean(stats)
        print('mean: ', Statistics.mean(stats))
        mean_rt[it, 0] = float(Statistics.mean(stats))
        # mean_rt=np.asarray(mean_rt)

    plt.plot(mean_rt)
    plt.xlabel('Lambda')
    plt.ylabel('Mean')
    plt.show()
...