Ask coding questions

← Back to all posts
Need help setting up Nix repl
igor5551

Hello Community!

I have a script that I want to run on replit but it crashes because talib (https://blog.quantinsti.com/install-ta-lib-python/) is not supported.

I have contacted support and they set this repl for me (https://replit.com/@igor5551/ta-lib-3) but it is still crashing and they confirmed they are working on an update.

They recommended that I use Nix repl (https://docs.replit.com/repls/nix) and that "should fix the package issue directly".

The problem is that I am still new to programming and I am not sure how to set up Nix to work with my script.

They suggested that I reach out to the fine people here as you are very knowledgeable and would be able to assist me.

I am hoping someone can assist me with this issue. Please let me know if I missed something or if you need more information.

Thank you!

Edit: the script I am trying to run is located here: https://replit.com/@igor5551/LightgreyMysteriousStaff#main.py

Voters
igor5551
Comments
hotnewtop
SixBeeps

Right so what you're going to want to do is to move all your code into a fresh Nix Repl. It should all go into a Python file, preferably named main.py, but anything will work.

Then, following the same syntax listed in the documentation you linked, add the pkgs.python39Full package. This will install Python 3.9 into the Nix environment. To actually go through the process of initiallizing the enviroment, click the run button. It should give you an error about cowsay not existing anymore.

Next, run pip install TA-Lib. The tutorial you linked says to use conda, but the official TA-Lib GitHub has us using pip instead. I don't know if Conda is packaged in with the Python install, so use pip just to be safe.

Finally, you're going to need to link the run button to the script. This is done in the .replit file with the run parameter. There should be something like cowsay Hello World! already in there, just replace it with python main.py and that'll make it run the script when you click the run button.

igor5551

@SixBeeps

Thank you so much for your reply. I followed your instructions and created/updated the 3 files. However when I get to the step "pip install TA-Lib" I get this error message "bash: pip: command not found".

Here is a link to my updated repl:
https://replit.com/@igor5551/Nix-Repl-test-script#replit.nix

Not sure what is causing this issue.

Thank you again!

SixBeeps

@igor5551 My bad, I forgot to mention you'll also need the pkgs.python39Packages.pip package. Nix keeps pip separate from its Python derivation.

igor5551

@SixBeeps

Thank you, I added the pip package and it works.

However when I run "pip install TA-Lib" I get a crash with the following message:

Collecting TA-Lib
Using cached TA-Lib-0.4.21.tar.gz (270 kB)
ERROR: Command errored out with exit status 1:
command: /nix/store/nki9ywqzbvz68vr75kn2r7g1q84f5agy-python3-3.9.6/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-txs7dgyp/ta-lib_a1473741609f48ba89fc5939f93e82b4/setup.py'"'"'; file='"'"'/tmp/pip-install-txs7dgyp/ta-lib_a1473741609f48ba89fc5939f93e82b4/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-3_dhv2di
cwd: /tmp/pip-install-txs7dgyp/ta-lib_a1473741609f48ba89fc5939f93e82b4/
Complete output (3 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'setuptools'

WARNING: Discarding https://files.pythonhosted.org/packages/40/36/ea7b36b5d46b489d3b7aba4281cb430279ef1980974ea513164e85261547/TA-Lib-0.4.21.tar.gz#sha256=74d2f24ca68aa299275f3179a9adde05cff959f91497e088487d0b5c85104e9f (from https://pypi.org/simple/ta-lib/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Using cached TA-Lib-0.4.20.tar.gz (266 kB)
ERROR: Command errored out with exit status 1:
command: /nix/store/nki9ywqzbvz68vr75kn2r7g1q84f5agy-python3-3.9.6/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-txs7dgyp/ta-lib_a9478c4ff33c49af964dce8e9eb0a386/setup.py'"'"'; file='"'"'/tmp/pip-install-txs7dgyp/ta-lib_a9478c4ff33c49af964dce8e9eb0a386/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-1lgfd7z6
cwd: /tmp/pip-install-txs7dgyp/ta-lib_a9478c4ff33c49af964dce8e9eb0a386/
Complete output (3 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'setuptools'

WARNING: Discarding https://files.pythonhosted.org/packages/1f/fd/cb3b4255f2639e3478d75750d06e0d8f3342d7f8f28e8d855198769d3ede/TA-Lib-0.4.20.tar.gz#sha256=89947bf28d265bb632060bdba77eb4f4d0e812c4e918c7377f129b4a3ee9a8e9 (from https://pypi.org/simple/ta-lib/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Using cached TA-Lib-0.4.19.tar.gz (267 kB)
ERROR: Command errored out with exit status 1:
command: /nix/store/nki9ywqzbvz68vr75kn2r7g1q84f5agy-python3-3.9.6/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-txs7dgyp/ta-lib_b72a5521cb2a4dc4a75c034dd01ab34b/setup.py'"'"'; file='"'"'/tmp/pip-install-txs7dgyp/ta-lib_b72a5521cb2a4dc4a75c034dd01ab34b/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-6868z486
cwd: /tmp/pip-install-txs7dgyp/ta-lib_b72a5521cb2a4dc4a75c034dd01ab34b/
Complete output (3 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'setuptools'

WARNING: Discarding https://files.pythonhosted.org/packages/ac/cf/681911aa31e04ba171ab4d523a412f4a746e30d3eacb1738799d181e028b/TA-Lib-0.4.19.tar.gz#sha256=5303227898f8f08baecb4d3b8767c85891b65b21f481a3ecbaa6e901c3531db5 (from https://pypi.org/simple/ta-lib/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Using cached TA-Lib-0.4.18.tar.gz (265 kB)
ERROR: Command errored out with exit status 1:
command: /nix/store/nki9ywqzbvz68vr75kn2r7g1q84f5agy-python3-3.9.6/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-txs7dgyp/ta-lib_7de27f91f93544379657173afb81b98d/setup.py'"'"'; file='"'"'/tmp/pip-install-txs7dgyp/ta-lib_7de27f91f93544379657173afb81b98d/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-fe4gr8kl
cwd: /tmp/pip-install-txs7dgyp/ta-lib_7de27f91f93544379657173afb81b98d/
Complete output (3 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'setuptools'

WARNING: Discarding https://files.pythonhosted.org/packages/d7/15/ebf1a6ebcf7580dc53e342979c7425affc38ef272bc10a7f4565ee87b394/TA-Lib-0.4.18.tar.gz#sha256=261d88fbca4b1923b37e0aad23512bc9b9245726c187344e432ee6a4a9a134a8 (from https://pypi.org/simple/ta-lib/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Using cached TA-Lib-0.4.17.tar.gz (717 kB)
ERROR: Command errored out with exit status 1:
command: /nix/store/nki9ywqzbvz68vr75kn2r7g1q84f5agy-python3-3.9.6/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-txs7dgyp/ta-lib_4b17f5e5b3df44f39c5b4f6fa0a31a15/setup.py'"'"'; file='"'"'/tmp/pip-install-txs7dgyp/ta-lib_4b17f5e5b3df44f39c5b4f6fa0a31a15/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-lq8w66mv
cwd: /tmp/pip-install-txs7dgyp/ta-lib_4b17f5e5b3df44f39c5b4f6fa0a31a15/
Complete output (3 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'setuptools'

WARNING: Discarding https://files.pythonhosted.org/packages/90/05/d4c6a778d7a7de0be366bc4a850b4ffaeac2abad927f95fa8ba6f355a082/TA-Lib-0.4.17.tar.gz#sha256=16ab1e33c547fe72c10c28b02f6ae342fbcc7eef6a49ba961c639a6020aba56a (from https://pypi.org/simple/ta-lib/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Using cached TA-Lib-0.4.16.tar.gz (715 kB)
ERROR: Command errored out with exit status 1:
command: /nix/store/nki9ywqzbvz68vr75kn2r7g1q84f5agy-python3-3.9.6/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-txs7dgyp/ta-lib_fe0d1da10289466f97645b3502d0d6d3/setup.py'"'"'; file='"'"'/tmp/pip-install-txs7dgyp/ta-lib_fe0d1da10289466f97645b3502d0d6d3/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-s98ag1is
cwd: /tmp/pip-install-txs7dgyp/ta-lib_fe0d1da10289466f97645b3502d0d6d3/
Complete output (3 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'setuptools'

WARNING: Discarding https://files.pythonhosted.org/packages/0a/7d/a5f64eadbac6cf7ee41f9ae88fcfee1ff0824ffea529efe1e5cb2dd7e60b/TA-Lib-0.4.16.tar.gz#sha256=555f5d9e6720ef935669c1f404a7179091ae35869c6435957709a7059b9fd1d7 (from https://pypi.org/simple/ta-lib/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Using cached TA-Lib-0.4.15.tar.gz (715 kB)
ERROR: Command errored out with exit status 1:
command: /nix/store/nki9ywqzbvz68vr75kn2r7g1q84f5agy-python3-3.9.6/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-txs7dgyp/ta-lib_c9c20d0a63784d22a935656090096631/setup.py'"'"'; file='"'"'/tmp/pip-install-txs7dgyp/ta-lib_c9c20d0a63784d22a935656090096631/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-q3w47jvg
cwd: /tmp/pip-install-txs7dgyp/ta-lib_c9c20d0a63784d22a935656090096631/
Complete output (3 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'setuptools'

WARNING: Discarding https://files.pythonhosted.org/packages/89/27/c3f1be143905daf12ca4c9a52e4f5cc538a97ad01b9cd0123fe7643666fd/TA-Lib-0.4.15.tar.gz#sha256=811d0ba366d243e2b158de1f5678f53171741e802319f8e0e7840e721fb51c0e (from https://pypi.org/simple/ta-lib/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Using cached TA-Lib-0.4.14.tar.gz (715 kB)
ERROR: Command errored out with exit status 1:
command: /nix/store/nki9ywqzbvz68vr75kn2r7g1q84f5agy-python3-3.9.6/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-txs7dgyp/ta-lib_0c46669cc1d44415a9fdf3df6e2217df/setup.py'"'"'; file='"'"'/tmp/pip-install-txs7dgyp/ta-lib_0c46669cc1d44415a9fdf3df6e2217df/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-8a6rfnr6
cwd: /tmp/pip-install-txs7dgyp/ta-lib_0c46669cc1d44415a9fdf3df6e2217df/
Complete output (3 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'setuptools'

WARNING: Discarding https://files.pythonhosted.org/packages/23/ac/da20341c64ae569535eaa786f849a598015ea77e5b6d957d3c674a35b01c/TA-Lib-0.4.14.tar.gz#sha256=375edf46c146d4d7b35e305bd06096acc7dd1728ff6dff2058cc21289f9b18a9 (from https://pypi.org/simple/ta-lib/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Using cached TA-Lib-0.4.9.zip (527 kB)
ERROR: Command errored out with exit status 1:
command: /nix/store/nki9ywqzbvz68vr75kn2r7g1q84f5agy-python3-3.9.6/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-txs7dgyp/ta-lib_3f3b1fb5a5ac4ad885209b7e3f2bd3fb/setup.py'"'"'; file='"'"'/tmp/pip-install-txs7dgyp/ta-lib_3f3b1fb5a5ac4ad885209b7e3f2bd3fb/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-x2ymvzjg
cwd: /tmp/pip-install-txs7dgyp/ta-lib_3f3b1fb5a5ac4ad885209b7e3f2bd3fb/
Complete output (3 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'setuptools'

WARNING: Discarding https://files.pythonhosted.org/packages/0d/85/d80e736cafde6239eef73dabf2b5d5db53ccb5552526a1c4b127caafe917/TA-Lib-0.4.9.zip#sha256=0601c6f7007c3cf4f585dd6fd45df55720ab38bcd91f19abb807cbcbe9f5b42a (from https://pypi.org/simple/ta-lib/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Using cached TA-Lib-0.4.9.tar.gz (495 kB)
ERROR: Command errored out with exit status 1:
command: /nix/store/nki9ywqzbvz68vr75kn2r7g1q84f5agy-python3-3.9.6/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-txs7dgyp/ta-lib_de1fd229ae0d47988080a9e10f5d52b5/setup.py'"'"'; file='"'"'/tmp/pip-install-txs7dgyp/ta-lib_de1fd229ae0d47988080a9e10f5d52b5/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-1zim9kxz
cwd: /tmp/pip-install-txs7dgyp/ta-lib_de1fd229ae0d47988080a9e10f5d52b5/
Complete output (3 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'setuptools'

WARNING: Discarding https://files.pythonhosted.org/packages/87/d3/59094a1816233adcb27159d4b0b54982eb5bde4513dba4d4f2e4f0467e3c/TA-Lib-0.4.9.tar.gz#sha256=102f7f763a90ae72dcbe9f842ec7e656007c0b4aa234899425f8be226e9c1cb9 (from https://pypi.org/simple/ta-lib/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement TA-Lib (from versions: 0.4.9, 0.4.14, 0.4.15, 0.4.16, 0.4.17, 0.4.18, 0.4.19, 0.4.20, 0.4.21)
ERROR: No matching distribution found for TA-Lib
WARNING: You are using pip version 21.1.3; however, version 21.3.1 is available.
You should consider upgrading via the '/nix/store/nki9ywqzbvz68vr75kn2r7g1q84f5agy-python3-3.9.6/bin/python3.9 -m pip install --upgrade pip' command.

SixBeeps

@igor5551 Yikes, I have no idea then. It says that it can't find TA-Lib, which is concerning given that it exists on PyPI. I'm afraid this is beyond my scope and I can't help you any further.

igor5551

@SixBeeps

Thank for getting me on the right path.

One additional question.

On the blog (https://blog.quantinsti.com/install-ta-lib-python/) where I found ta-lib instructions I see it says

"Step 2: We cannot directly use the "pip install" command when it comes to installing Ta-Lib. Thus, we will first install the "whl" file which can be found on this link: https://www.lfd.uci.edu/~gohlke/pythonlibs/#ta-lib"

Do you think there is a way to add this whl file somewhere in Nix repl and then install it?

SixBeeps

@igor5551 Yeah I have no idea how to work with wheels. Though, if you know how to install a wheel normally, it should be the same process.