简体   繁体   中英

OSError: [WinError 126] with Python

I am running Python 3.7 on Windows 10, and trying to run a program that requires Python 3.x, pycuda, and Cuda.

  • Installed all of these, including Cuda 10.2.
  • Also added C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin to path.

When I enter the directory where the program is and try to run it, this is what I get:

C:\Users\alero\HELIOS-master>python3 helios.py
Traceback (most recent call last):
  File "helios.py", line 25, in <module>
    from source import read
  File "C:\Users\alero\HELIOS-master\source\read.py", line 26, in <module>
    from scipy import interpolate
  File "C:\Users\alero\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\scipy\__init__.py", line 130, in <module>
    from . import _distributor_init
  File "C:\Users\alero\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\scipy\_distributor_init.py", line 61, in <module>
    WinDLL(os.path.abspath(filename))
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

What is the actual problem and how can I fix it?

EDIT: this is the program I am trying to run

from source import read
from source import quantities as quant
from source import host_functions as hsfunc
from source import write
from source import computation as comp
from source import realtime_plotting as rt_plot
from source import clouds
from source import Vcoupling_modification as Vmod

def run_helios():
    """ runs a normal HELIOS run with standard I/O """

    reader = read.Read()
    keeper = quant.Store()
    computer = comp.Compute()
    writer = write.Write()
    plotter = rt_plot.Plot()
    cloudy = clouds.Cloud()
    Vmodder = Vmod.Vcoupling()

    # read input files and do preliminary calculations
    reader.read_param_file_and_command_line(keeper, Vmodder)

    if Vmodder.V_coupling == 1:
        Vmodder.read_or_create_iter_count()
        Vmodder.read_species()
        Vmodder.read_molecular_opacities(keeper)
        Vmodder.read_layer_molecular_abundance(keeper)
    reader.read_opac_file(keeper, Vmodder)
    reader.read_kappa_table(keeper)
    cloudy.main_cloud_method(keeper)
    keeper.dimensions()
    reader.read_star(keeper)
    hsfunc.planet_param(keeper, reader)
    hsfunc.set_up_numerical_parameters(keeper)
    hsfunc.construct_grid(keeper)
    hsfunc.initial_temp(keeper, reader, Vmodder)
    if keeper.approx_f == 1:
        hsfunc.approx_f_from_formula(keeper, reader)
    hsfunc.calc_F_intern(keeper)


    # get ready for GPU computations
    keeper.create_zero_arrays(Vmodder)
    keeper.convert_input_list_to_array(Vmodder)
    keeper.copy_host_to_device(Vmodder)
    keeper.allocate_on_device(Vmodder)

    # conduct the GPU core computations
    computer.construct_planck_table(keeper)
    computer.correct_incident_energy(keeper)

    if Vmodder.V_coupling == 1:
        if Vmodder.V_iter_nr > 0:
            Vmodder.interpolate_f_molecule_and_meanmolmass(keeper)
            Vmodder.combine_to_scat_cross(keeper)

    computer.radiation_loop(keeper, writer, reader, plotter, Vmodder)

    computer.convection_loop(keeper, writer, reader, plotter, Vmodder)

    computer.integrate_optdepth_transmission(keeper)
    computer.calculate_contribution_function(keeper)
    computer.interpolate_entropy(keeper)
    computer.interpolate_phase_state(keeper)
    computer.calculate_mean_opacities(keeper)
    computer.integrate_beamflux(keeper)

    # copy everything back to host and write to files
    keeper.copy_device_to_host()
    hsfunc.calculate_conv_flux(keeper)
    hsfunc.calc_F_ratio(keeper)
    writer.write_info(keeper, reader, Vmodder)
    writer.write_colmass_mu_cp_entropy(keeper, reader)
    writer.write_integrated_flux(keeper, reader)
    writer.write_downward_spectral_flux(keeper, reader)
    writer.write_upward_spectral_flux(keeper, reader)
    writer.write_TOA_flux_eclipse_depth(keeper, reader)
    writer.write_direct_spectral_beam_flux(keeper, reader)
    writer.write_planck_interface(keeper, reader)
    writer.write_planck_center(keeper, reader)
    writer.write_tp(keeper, reader)
    writer.write_tp_cut(keeper, reader)
    writer.write_opacities(keeper, reader)
    writer.write_Rayleigh_cross_sections(keeper, reader)
    writer.write_cloud_scat_cross_sections(keeper, reader)
    writer.write_cloud_absorption(keeper, reader)
    writer.write_g_0(keeper, reader)
    writer.write_transmission(keeper, reader)
    writer.write_opt_depth(keeper, reader)
    writer.write_trans_weight_function(keeper, reader)
    writer.write_contribution_function(keeper, reader)
    writer.write_mean_extinction(keeper, reader)
    writer.write_flux_ratio_only(keeper, reader)
    writer.write_phase_state(keeper, reader)

    if Vmodder.V_coupling == 1:
        Vmodder.write_tp_VULCAN(keeper)
    if keeper.approx_f == 1:
        hsfunc.calc_tau_lw_sw(keeper, reader)

    # prints the success message - yay!
    hsfunc.success_message(keeper)

    if Vmodder.V_coupling == 1:
        Vmodder.test_coupling_convergence(keeper)


def main():
    """ runs the HELIOS RT computation if this file is executed """

    if __name__ == "__main__":

        run_helios()

main()

I guess that somewhere in your script you have added a path...which is giving the error

If that's true: There are basically 3 solutions a) Use double slashes...

something="c:\\aaaa\\bbbbb\\ccccc"

b) use forward slashes

something = "c:/aaaa/bbbbb/ccccc"

c) use RAW strings (prefacing the string with r)

something = r"c:\aaaa\bbbb\cccc"

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