0

I have to use tensorflow on a server where I don't have access to pip install or anything like that.

I know for custom python modules you want to import you can usually just do

import sys
sys.path.append('path/to/module')
import module

Is there a way I can just download tensorflow library and import it like this?

89f3a1c
  • 1,430
  • 1
  • 14
  • 24
LJ O
  • 11
  • 2

1 Answers1

0

I often find myself in similar situations when I have to run Python scripts that use 3rd party modules in servers where I do not have access to a cmd.

One solution is to install the package within the Python script, using the following function (taken from this answer):

You can also use something like:

import pip

def install(package):
    if hasattr(pip, 'main'):
        pip.main(['install', package])
    else:
        pip._internal.main(['install', package])

This way you can install Tensorflow running install('tensorflow).

Marcelo Villa-Piñeros
  • 1,101
  • 2
  • 12
  • 24
  • Thank you for your response. The problem with this answer is that installing the package won't help me, since all I can do is reference files on the server, not packages installed on the server machine. – LJ O Jul 11 '19 at 17:20