0

This might be a dumb question but I forked the Keras repo, cloned it, created a new branch, performed some modifications and created a PR.

Now I would like to use this module with my modifications.

To do that I would like to install it in a virtualenv. From what I have read there are two ways: one is to install it from the Pull Request link, the other from the local folder.

In the latter case I tried the command described here:

pip3 install keras --no-index --find-links file:///home/my_usr/keras/

but I got the error

ERROR: Could not find a version that satisfies the requirement keras (from versions: none)

ERROR: No matching distribution found for keras

In the former case I tried the command shown here by running:

pip3 install git+https://github.com/keras-team/keras.git@refs/pull/16830/head

but in this case I got the error:

ERROR: git+https://github.com/keras-team/keras.git@refs/pull/16830/head does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found.

How can I do that?

EDIT

I did some steps forward following this guide (being sure that I am on my correct branch) and using the same folder structure of the post.

However, after the steps, when importing imdb I get the error:

Traceback (most recent call last): File "", line 1, in File "/home/my_user/keras_installation/keras/keras/init.py", line 21, in from keras import models File "/home/my_user/keras_installation/keras/keras/models/init.py", line 18, in from keras.engine.functional import Functional File "/home/my_user/keras_installation/keras/keras/engine/functional.py", line 27, in from keras.dtensor import layout_map as layout_map_lib File "/home/my_user/keras_installation/keras/keras/dtensor/layout_map.py", line 27, in from keras.engine import base_layer File "/home/my_user/keras_installation/keras/keras/engine/base_layer.py", line 43, in from keras.saving.saved_model import layer_serialization File "/home/my_user/keras_installation/keras/keras/saving/saved_model/layer_serialization.py", line 22, in from keras.saving.saved_model import save_impl File "/home/my_user/keras_installation/keras/keras/saving/saved_model/save_impl.py", line 34, in from keras.saving.saved_model import load as keras_load File "/home/my_user/keras_installation/keras/keras/saving/saved_model/load.py", line 29, in from keras.protobuf import saved_metadata_pb2 ImportError: cannot import name 'saved_metadata_pb2' from 'keras.protobuf' (unknown location)

roschach
  • 8,390
  • 14
  • 74
  • 124
  • This has nothing to do with *Git*. It's just a question about "how do I make Python import module M from path P2 instead of path P1". (The general answer is "via PYTHONPATH or equivalent such as venv") – torek Jul 26 '22 at 04:38
  • Ok, you are right. Nevertheless, the problem remains. I tried to clarify my question with some examples. I hope I have improved my question – roschach Jul 26 '22 at 15:58
  • I think it is improved, yes - we now know you're looking for something that will help with pip3 as well (so I added that tag). – torek Jul 26 '22 at 20:46
  • @francescoboi Have you checked pip's own documentation instead of possibly outdated StackOverflow answers? https://pip.pypa.io/en/stable/cli/pip_install/ – sinoroc Jul 26 '22 at 21:28
  • Installing from git: https://pip.pypa.io/en/stable/topics/vcs-support/ -- Installing from local directory: https://pip.pypa.io/en/stable/topics/local-project-installs/ – sinoroc Jul 26 '22 at 21:30
  • Did you try navigating to your keras directory and running `pip3 install .`? – Filip Müller Jul 26 '22 at 21:31
  • Also, you should never call `pip3` or `pip` or any `pipX.Y` script. Instead always use the `-m` form, something like `path/to/pythonX.Y -m pip install ...`, see: https://snarky.ca/why-you-should-use-python-m-pip/ – sinoroc Jul 26 '22 at 21:33
  • I found this resource: https://towardsdatascience.com/building-keras-from-source-a-follow-along-guide-2bcc4cea3aec. You cannot directly pip3 install but have to build first. However, after the build I cannot find the keras_pkg folder. – roschach Aug 16 '22 at 09:25

0 Answers0