1

I am trying to use the modules I am developing like a package using python -m pip install -e . - I ran this command inside the package directory where setup.py is at the root of the directory.

I am getting the same error using python -m pip install git+https://github.com/user/repo_name.git@main

Here is the github repo I am trying to make it into a python package: repo_link

This is my first time working on creating a python package. I followed online documentations to do all of this.

Error

ERROR: Exception:
Traceback (most recent call last):
  File "D:\AnacondaFinal\anacondaInstall\envs\test_env\lib\site-packages\pip\_internal\cli\base_command.py", line 180, in exc_logging_wrapper
    status = run_func(*args)
  File "D:\AnacondaFinal\anacondaInstall\envs\test_env\lib\site-packages\pip\_internal\cli\req_command.py", line 245, in wrapper
    return func(self, options, args)
  File "D:\AnacondaFinal\anacondaInstall\envs\test_env\lib\site-packages\pip\_internal\commands\install.py", line 377, in run
    requirement_set = resolver.resolve(
  File "D:\AnacondaFinal\anacondaInstall\envs\test_env\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 76, in resolve
    collected = self.factory.collect_root_requirements(root_reqs)
  File "D:\AnacondaFinal\anacondaInstall\envs\test_env\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 534, in collect_root_requirements
    reqs = list(
  File "D:\AnacondaFinal\anacondaInstall\envs\test_env\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 490, in _make_requirements_from_install_req
    cand = self._make_base_candidate_from_link(
  File "D:\AnacondaFinal\anacondaInstall\envs\test_env\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 207, in _make_base_candidate_from_link
    self._editable_candidate_cache[link] = EditableCandidate(
  File "D:\AnacondaFinal\anacondaInstall\envs\test_env\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 315, in __init__
    super().__init__(
  File "D:\AnacondaFinal\anacondaInstall\envs\test_env\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 156, in __init__
    self.dist = self._prepare()
  File "D:\AnacondaFinal\anacondaInstall\envs\test_env\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 222, in _prepare
    dist = self._prepare_distribution()
  File "D:\AnacondaFinal\anacondaInstall\envs\test_env\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 325, in _prepare_distribution
    return self._factory.preparer.prepare_editable_requirement(self._ireq)
  File "D:\AnacondaFinal\anacondaInstall\envs\test_env\lib\site-packages\pip\_internal\operations\prepare.py", line 696, in prepare_editable_requirement
    dist = _get_prepared_distribution(
  File "D:\AnacondaFinal\anacondaInstall\envs\test_env\lib\site-packages\pip\_internal\operations\prepare.py", line 71, in _get_prepared_distribution
    abstract_dist.prepare_distribution_metadata(
  File "D:\AnacondaFinal\anacondaInstall\envs\test_env\lib\site-packages\pip\_internal\distributions\sdist.py", line 37, in prepare_distribution_metadata
    self.req.load_pyproject_toml()
  File "D:\AnacondaFinal\anacondaInstall\envs\test_env\lib\site-packages\pip\_internal\req\req_install.py", line 516, in load_pyproject_toml
    pyproject_toml_data = load_pyproject_toml(
  File "D:\AnacondaFinal\anacondaInstall\envs\test_env\lib\site-packages\pip\_internal\pyproject.py", line 64, in load_pyproject_toml
    pp_toml = tomli.loads(f.read())
  File "D:\AnacondaFinal\anacondaInstall\envs\test_env\lib\site-packages\pip\_vendor\tomli\_parser.py", line 102, in loads
    pos = key_value_rule(src, pos, out, header, parse_float)
  File "D:\AnacondaFinal\anacondaInstall\envs\test_env\lib\site-packages\pip\_vendor\tomli\_parser.py", line 349, in key_value_rule
    raise suffixed_err(src, pos, "Cannot overwrite a value")
pip._vendor.tomli.TOMLDecodeError: Cannot overwrite a value (at line 13, column 21)

Here is the structure of package - FOO

  • Initial_codes (contains jupyter notebooks)
  • Quantum_Simulations (jupyter notebooks)
  • src/Package_name
    • __init__.py
    • Module1.py
    • Module2.py
    • Module3.py
  • Tutorial Notebooks (jupyter notebooks and py file)
  • citation.cff
  • setup.py
  • setup.cfg
  • requirements_for_pip.txt
  • requirements_conda.txt
  • LICENSE
  • pyproject.toml
9
  • Did you examine what requirements.txt normally is in other packages? For example, Pandas. Yours doesn't look correct. You don't want everything in there. You want to probably start with a minimum and then limit what is needed as it is in various situations. Also the convention is is environment.yml for conda. I don't know if it works with .txt as a list and not yaml. Did you follow a tutorial? Your title needs to be specific to your issue and not general. For example, if you use a repo that was set up correctly, does it work? If so, then your ... Commented Sep 5, 2024 at 12:08
  • <continued> title is a false statement. Read and use How do I ask a good question?. It has a section on writing a title. Commented Sep 5, 2024 at 12:12
  • Never seen this error before. -- I tried to reproduce the issue but couldn't, for it installed fine without any problem at all. Commented Sep 5, 2024 at 18:55
  • @sinoroc I think this error was from the pyproject.toml file. I had some variables repeated in different parts of the file. I used [toml-lint.com/](toml_verification) for checking the errors in the toml file. After correcting these errors, it was fine. Commented Sep 6, 2024 at 9:06
  • @Wayne I used pip3 freeze > requirements.txt to get the requirements.txt file. Is it necessary to provide dependencies in toml file? For my package, I only need numpy, scipy and matplotlib - all of their versions must be compatible with Python. Commented Sep 6, 2024 at 9:11

1 Answer 1

0

"TOMLDecodeError: Cannot overwrite a value" - I got this error since I had defined certain variables in different parts of the .toml file several times. I had some issues with improper closing/opening brackets too. However, this error got resolved once I corrected these issues. I used toml verification to debug the .toml file.

Also, setup.py or setup.cfg is not required for publishing the software package on PyPi.

Sign up to request clarification or add additional context in comments.

1 Comment

This is not an answer

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.