Importing module from network

后端 未结 6 1565
南笙
南笙 2020-12-21 04:22

Is there a way to get python to read modules from a network?

We have many machines and it would be a too much effort to update each machine manually each time I cha

相关标签:
6条回答
  • 2020-12-21 04:33

    How I ended up doing this:

    Control Panel\All Control Panel Items\System >> Advanced >> Environment Variables >> System Variables >> New >> Name = PYTHONPATH, value = \server\scriptFolder

    Thanks everyone for all the help :)

    0 讨论(0)
  • 2020-12-21 04:34

    It might be notable that a module for importing packages/modules available through HTTP/S exists and it is httpimport. This is for both Python2 and Python3.

    So, as of the accepted answer, it turns out that there are ways to programmatically import remote modules "like javascript" as follows:

    >>> with httpimport.remote_repo(['package1'], 'http://my-codes.example.com/python_packages'):
    ...     import package1
    ...
    >>> # -- 'package1' code is available here --
    
    0 讨论(0)
  • 2020-12-21 04:35
    sys.path.append(r'\\network\path')
    import module
    
    0 讨论(0)
  • 2020-12-21 04:40

    Mount your network location into your file-system and add that path to your PYTHONPATH. That way, Python on your local machine will be able to see the modules which are present in the remote location. You cannot directly import from modules remotely, like specifying a js file in html.

    0 讨论(0)
  • 2020-12-21 04:42

    While it's a little pathological to want to import modules over the network, it is actually possible. Take a look at the source for zipimport to get an idea of how it can be done.

    0 讨论(0)
  • 2020-12-21 04:47

    I believe you're looking for a distributed computing framework, where you deploy code and data to one node and they are distributed as task among a cluster of clients/servers/peers. Check Pyro, execnet, Parallel Python, Jug and RPyC.

    0 讨论(0)
提交回复
热议问题