简体   繁体   中英

OSError: [WinError 126] The specified module could not be found?

Firstly sorry, my grammer might be bad. And if I missed any solutions in here, you can give me url, but I did not find any proper one for this case.

I'm taking a course about deep learning, and they provide us to this code. However there was an error which I encounter only. This is the main.py;

from __future__ import print_function
import os
import torch
import torch.multiprocessing as mp
from envs import create_atari_env
from model import ActorCritic
from train import train
from testt import test
import my_optim

# Gathering all the parameters (that we can modify to explore)
class Params():
    def __init__(self):
        self.lr = 0.0001
        self.gamma = 0.99
        self.tau = 1.
        self.seed = 1
        self.num_processes = 16
        self.num_steps = 20
        self.max_episode_length = 10000
        self.env_name = 'Breakout-v0'

# Main run
os.environ['OMP_NUM_THREADS'] = '1'
params = Params()
torch.manual_seed(params.seed)
env = create_atari_env(params.env_name)
shared_model = ActorCritic(env.observation_space.shape[0], env.action_space)
shared_model.share_memory()
optimizer = my_optim.SharedAdam(shared_model.parameters(), lr=params.lr)
optimizer.share_memory()
processes = []
p = mp.Process(target=test, args=(params.num_processes, params, shared_model))
p.start()
processes.append(p)
for rank in range(0, params.num_processes):
    p = mp.Process(target=train, args=(rank, params, shared_model, optimizer))
    p.start()
    processes.append(p)
for p in processes:
    p.join()

Is it caused by "from envs import create_atari_env". Because after install create_atari_env, after I install it. And also I do not use any paths in scripts.

Error;

****\lib\ctypes_ init _.py line 426 in LoadLibrary self._handle = _dlopen(self._name, mode) OSError: [WinError 126] The specified module could not be found

This error is often caused in relation to path , for example, which requires the correct use of double-slashes , forward-slashes or raw-strings but since you mentioned this wasn't your case I believe the root cause of this error is by

import torch

There are known cases of PyTorch breaking DLL loading on specific Python and PyTorch versions (applies to PyTorch 1.5.0 on Python 3.7 specifically). Once you run import torch, any further DLL loads will fail. So if you're using PyTorch and loading your own DLLs you'll have to rearrange your code to import all DLLs first and then import torch .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM