Reputation: 1889
Is there some kind of workaround to create alias for python package..
What I want to do is to create an alias such that
from keras import LSTM
and the following code are same.
from albatross import LSTM
NOTE: I tried installing Keras from the github repo by modifying the name of the package in setup.py, but it is of no use.
Is there any way to do this in python (3) ?
EDIT: I'm not interested in the following way, as I don't want keras to be specified anywhere in the program code
import keras as albatross
Upvotes: 1
Views: 260
Reputation: 16730
If you're using a UNIX system, then a link will do what you want.
Suppose you want to import the keras
module, but with the name albatross
.
You can first find where the keras
module is installed, by importing it and looking at its file
attribute:
$ python
>>> import keras
Using TensorFlow backend.
>>> keras.__file__
'/home/<username>/.local/lib/python3.5/site-packages/keras/__init__.py'
Now, you can create a symbolic link to the keras/
directory, right next to it:
$ cd /home/<username>/.local/lib/python3.5site-packages
$ ln -s keras albatross
You'll find yourself with a link named albatross
, pointing to the keras
directory.
Now, importing albatross
will work, system-wide, and will effectively import keras
:
$ python
>>> import albatross
Using TensorFlow backend.
Upvotes: 2