Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install error 'The version specified ('egg_info') is an invalid version' #197

Closed
Smidelis opened this issue Mar 28, 2022 · 6 comments
Closed
Labels
user support Help a user

Comments

@Smidelis
Copy link

Smidelis commented Mar 28, 2022

The problem

Hi, first of all thanks for the great work! I am running Freqtrade via docker and wanted to import your indicators into my strategy. I am using a custom dockerfile to install stock-indicators. I couldnt install the version from PyPI (pip3 install stock-indicators) because it's still using pythonnet==2.5.2 which throws an error during install. Now i'm cloning the git repo and try to install it from the repo directly. I got a step further including the following lines in my custom dockerfile but unfortunately i still can't install stock-indicators.

Dockerfile.custom:

FROM freqtradeorg/freqtrade:develop

# Switch user to root if you must install something from apt
# Don't forget to switch the user back below!
USER root
RUN apt-get install git -y
USER ftuser

# Install pandas-ta
RUN pip install pandas_ta

# Requirements for stock-indicators 
# https://github.com/DaveSkender/Stock.Indicators.Python
RUN git clone https://github.com/DaveSkender/Stock.Indicators.Python.git
RUN pip3 install Stock.Indicators.Python/

Error message(s):

Step 6/7 : RUN git clone https://github.com/DaveSkender/Stock.Indicators.Python.git
 ---> Running in 5b711150edb1
Cloning into 'Stock.Indicators.Python'...
Removing intermediate container 5b711150edb1
 ---> 991ad892e105
Step 7/7 : RUN pip3 install Stock.Indicators.Python/
 ---> Running in f484901aff58
Defaulting to user installation because normal site-packages is not writeable
Processing ./Stock.Indicators.Python
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      /home/ftuser/.local/lib/python3.9/site-packages/setuptools/dist.py:530: UserWarning: The version specified ('egg_info') is an invalid version, this may not work as expected with newer versions of setuptools, pip, and PyPI. Please see PEP 440 for more details.
        warnings.warn(
      usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
         or: setup.py --help [cmd1 cmd2 ...]
         or: setup.py --help-commands
         or: setup.py cmd --help
      
      error: option --egg-base not recognized
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
The command '/bin/sh -c pip3 install Stock.Indicators.Python/' returned a non-zero code: 1
ERROR: Service 'freqtrade_dev1_bin_dry' failed to build : Build failed

Versions:
python: 3.9.9
pip3: 22.0.4
setuptools: 61.2.0

Thanks for your help.

@Smidelis Smidelis added the bug Something isn't working label Mar 28, 2022
@LeeDongGeon1996
Copy link
Member

LeeDongGeon1996 commented Mar 28, 2022

Hi, thank you for being our user and detail report. Based on my experience, it was not easy to troubleshoot when installing pythonnet.

There are two solutions for you:

  1. (RECOMMENDED)If you are available to use Conda environment, I recommend you to run conda install -c conda-forge pythonnet for pythonnet and use our current official release.
  2. Or, if you still want to install directly from the repo, you should build first and install the wheel by running:
    # Requirements: wheel
    # 3.6.1 is not official release version number, but needed for unofficial build. 
    python setup.py 0.6.1 bdist_wheel
    pip install dist/stock_indicators-0.6.1-py3-none-any.whl

@Smidelis
Copy link
Author

Thanks for your answer!

  1. I want to keep freqtrade as default as possible, so i tried without installing conda.
  2. Got it running with the following line in my custom dockerfile RUN git clone https://github.com/DaveSkender/Stock.Indicators.Python.git && cd Stock.Indicators.Python/ && python3 setup.py 0.6.1 bdist_wheel && pip3 install dist/stock_indicators-0.6.1-py3-none-any.whl

The build is completed now and i can run the freqtrade instance. Unfortunately the stock-indicator imports are throwing an error. Do i need to install anything else?

2022-03-28 20:19:23,716 - freqtrade.freqtradebot - INFO - Starting freqtrade docker-88f6663f
2022-03-28 20:19:23,993 - freqtrade.commands.trade_commands - ERROR - Could not find libmono
2022-03-28 20:19:23,993 - freqtrade.commands.trade_commands - ERROR - Fatal exception!
Traceback (most recent call last):
  File "/freqtrade/freqtrade/commands/trade_commands.py", line 18, in start_trading
    worker = Worker(args)
  File "/freqtrade/freqtrade/worker.py", line 35, in __init__
    self._init(False)
  File "/freqtrade/freqtrade/worker.py", line 52, in _init
    self.freqtrade = FreqtradeBot(self._config)
  File "/freqtrade/freqtrade/freqtradebot.py", line 58, in __init__
    self.strategy: IStrategy = StrategyResolver.load_strategy(self.config)
  File "/freqtrade/freqtrade/resolvers/strategy_resolver.py", line 44, in load_strategy
    strategy: IStrategy = StrategyResolver._load_strategy(
  File "/freqtrade/freqtrade/resolvers/strategy_resolver.py", line 190, in _load_strategy
    strategy = StrategyResolver._load_object(paths=abs_paths,
  File "/freqtrade/freqtrade/resolvers/iresolver.py", line 142, in _load_object
    (module, module_path) = cls._search_object(directory=_path,
  File "/freqtrade/freqtrade/resolvers/iresolver.py", line 124, in _search_object
    obj = next(cls._get_valid_object(module_path, object_name), None)
  File "/freqtrade/freqtrade/resolvers/iresolver.py", line 85, in _get_valid_object
    spec.loader.exec_module(module)  # type: ignore # importlib does not use typehints
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/freqtrade/user_data/strategies/Hasensachen_v0316.py", line 16, in <module>
    import stock_indicators.indicators as sta
  File "/home/ftuser/.local/lib/python3.9/site-packages/stock_indicators/indicators/__init__.py", line 1, in <module>
    from stock_indicators import _cslib
  File "/home/ftuser/.local/lib/python3.9/site-packages/stock_indicators/_cslib/__init__.py", line 12, in <module>
    import clr
  File "/home/ftuser/.local/lib/python3.9/site-packages/clr.py", line 6, in <module>
    load()
  File "/home/ftuser/.local/lib/python3.9/site-packages/pythonnet/__init__.py", line 36, in load
    set_default_runtime()
  File "/home/ftuser/.local/lib/python3.9/site-packages/pythonnet/__init__.py", line 22, in set_default_runtime
    set_runtime(clr_loader.get_mono())
  File "/home/ftuser/.local/lib/python3.9/site-packages/clr_loader/__init__.py", line 21, in get_mono
    libmono = find_libmono(sgen)
  File "/home/ftuser/.local/lib/python3.9/site-packages/clr_loader/util/find.py", line 67, in find_libmono
    raise RuntimeError("Could not find libmono")
RuntimeError: Could not find libmono

@LeeDongGeon1996
Copy link
Member

LeeDongGeon1996 commented Mar 29, 2022

Looks like the error is from pythonnet and it's telling you don't have Mono runtime on your system. To use pythonnet in Unix-based system, you must have Mono runtime installed.

(They have been trying to avoid Mono dependency. AFAIK, it is already available in their dev branch, but I'm not sure it will be compatible with stock-indicators.)

@Smidelis
Copy link
Author

Smidelis commented Mar 29, 2022

Thanks for yor links, managed to get it installed from the mono-project page instructions.
Unfortunately getting a different error now.

2022-03-29 09:53:56,327 - freqtrade.strategy.strategy_wrapper - ERROR - Unexpected error No method matches given arguments for Add: (<class 'str'>) calling <bound method IStrategy._analyze_ticker_internal of <Hasensachen_v0316.Hasensachen_v0316 object at 0x7fee273716d0>>
Python.Runtime.PythonException: 'str' value cannot be converted to Skender.Stock.Indicators.Quote

The above exception was the direct cause of the following exception:

System.ArgumentException: 'str' value cannot be converted to Skender.Stock.Indicators.Quote in method Void Add(Skender.Stock.Indicators.Quote) ---> Python.Runtime.PythonException: 'str' value cannot be converted to Skender.Stock.Indicators.Quote
   --- End of inner exception stack trace ---

The above exception was the direct cause of the following exception:

System.AggregateException: One or more errors occurred. ('str' value cannot be converted to Skender.Stock.Indicators.Quote in method Void Add(Skender.Stock.Indicators.Quote)) ---> System.ArgumentException: 'str' value cannot be converted to Skender.Stock.Indicators.Quote in method Void Add(Skender.Stock.Indicators.Quote) ---> Python.Runtime.PythonException: 'str' value cannot be converted to Skender.Stock.Indicators.Quote
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.ArgumentException: 'str' value cannot be converted to Skender.Stock.Indicators.Quote in method Void Add(Skender.Stock.Indicators.Quote) ---> Python.Runtime.PythonException: 'str' value cannot be converted to Skender.Stock.Indicators.Quote
   --- End of inner exception stack trace ---<---


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/freqtrade/freqtrade/strategy/strategy_wrapper.py", line 21, in wrapper
    return f(*args, **kwargs)
  File "/freqtrade/freqtrade/strategy/interface.py", line 544, in _analyze_ticker_internal
    dataframe = self.analyze_ticker(dataframe, metadata)
  File "/freqtrade/freqtrade/strategy/interface.py", line 523, in analyze_ticker
    dataframe = self.advise_indicators(dataframe, metadata)
  File "/freqtrade/freqtrade/strategy/interface.py", line 921, in advise_indicators
    return self.populate_indicators(dataframe, metadata)
  File "/freqtrade/user_data/strategies/Hasensachen_v0316.py", line 234, in populate_indicators
    dataframe['sma'] = indicators.get_sma(dataframe, 20)
  File "/home/ftuser/.local/lib/python3.9/site-packages/stock_indicators/indicators/sma.py", line 33, in get_sma
    sma_list = CsIndicator.GetSma[Quote](CsList(Quote, quotes), lookback_periods)
  File "/home/ftuser/.local/lib/python3.9/site-packages/stock_indicators/_cstypes/list.py", line 34, in __new__
    clist.Add(i)
TypeError: No method matches given arguments for Add: (<class 'str'>)

The variable dataframe is a pandas dataframe containing the ohlcv data e.g. close price would be dataframe['close']. With dataframe['sma'] i'm adding another series with the sma values. I dont know what exactly you are expecting as quotes. Is this error related to the variable i'm passing to indicators.get_sma or is it a different one?

If this is getting to complicated now, i'd be fine if we close the issue. Was interested in some of your indicators but then i need to try to write them by myself or find a different library.

@LeeDongGeon1996
Copy link
Member

LeeDongGeon1996 commented Mar 29, 2022

Yeah, it's about the parameter. You are passing pandas.dataframe instance for quotes. But our library has its own Quote class, stock_indicators.indicators.common.quote.Quote. You have to pass Iterable object of our Quote instances. You can create like this:

from stock_indicators.indicators.common.quote import Quote

quotes = [ Quote(date, o, h, l, c, v) for date, o, h, l, c, v in your_feed ]        

Also, we already have well-organized documentation, please refer to:

@LeeDongGeon1996 LeeDongGeon1996 added the good first issue Good for newcomers label Mar 30, 2022
@LeeDongGeon1996
Copy link
Member

Thank you for the good first issue. If you have further questions, always welcome :)

@LeeDongGeon1996 LeeDongGeon1996 added question Further information is requested and removed bug Something isn't working good first issue Good for newcomers labels Mar 30, 2022
@LeeDongGeon1996 LeeDongGeon1996 added user support Help a user and removed question Further information is requested labels May 8, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
user support Help a user
Projects
None yet
Development

No branches or pull requests

2 participants