![]() |
|
pip install in python code? - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: pip install in python code? (/showthread.php?tid=6241224) |
pip install in python code? - dbCooker - May 9, 2023 Is there a way to have my installrequirements.bat file implemented into my python code. The install requirements consists of "pip install tensorflow numpy". And the python code is a very simple chatbot, the first lines are, "import tensorflow as tf import numpy as np import os import re import unicodedata import io import time # Define constants BUFFER_SIZE = 20000 BATCH_SIZE = 64 EMBEDDING_DIM = 256 UNITS = 1024 MAX_LENGTH = 40" Please feel free to reply. Kind regards, Xolu :) RE: pip install in python code? - ALEDIO - May 9, 2023 (May 9, 2023 05:55 PM)Xolu Wrote: Is there a way to have my installrequirements.bat file implemented into my python code. It is obvious that it is possible to do all this, you can very well make a .bat file where you simply insert the commands it should execute and some graphical hints to improve the user experience. Actually you could make a requirements file in txt, that too would have its why. It's extremely easy to do, just Google it and in less than 5 minutes you're done. RE: pip install in python code? - NyQuil - May 17, 2023 you didnt really show much of what your actual error was but looking into your error i found this which is installing the correct stuff i hope https://www.tensorflow.org/install/pip#linux RE: pip install in python code? - Perlo - May 18, 2023 Yes, there is a package in python called subprocess. This allows your python code to run things in command line. You can let it run pip install -r requirements.txt for you. Code import subprocessHowever, if you put in the code you had, it will not run because it first imports package which may have not yet been installed by the requirements.txt. One way to do it would be. Create a python file that will run the above mentioned code and installs the requirements.txt, then in the same code below installing the requirements.txt you could create another subprocess.run() which would call the python file which includes the just installed packages (the code you mentioned in your post). RE: pip install in python code? - Kalvaxas - Jun 8, 2023 (May 9, 2023 05:55 PM)Xolu Wrote: Is there a way to have my installrequirements.bat file implemented into my python code. You'd just need to use the subprocess library, HOWEVER, since you're using pip install in your actual code - You'd need to install it first (in your code) and then enter the rest of your code after the install process. Like so. Code import subprocessRE: pip install in python code? - Hackers - Jun 10, 2023 If you are looking for a single executable bat, then you need to handle the installation of everything - including python itself if you are on a new machine, all necessary PATH updates, package installations (ex: tensorflow), and also be able to handle directory traversing so you can make sure things are in correct spots. Then from there you can just run your Python script using a normal command and as others have said - subprocess (in other langs I think they use something called childprocess for this too) - to execute anything else you need. From there everything inside of your Python script will run :) |