Hello to evryone. I'm new to Vertex AI and I'm learning step by step.
I'm wondering, it is possible to use PIP on Vertex AI workbench but instead of pointing at PyPI by default, pointing to a python artifact registry containing pre-installed python packages? This is due to the fact that for project constraints, it is not possible to direcly reach outside internet.
Good day @domistingi,
Welcome to Google Cloud Community!
You can try installing the package from PyPI using the pip install and include --index-url option, this will specify the package you want to install and it will install the package to the private server. Here is the sample code:
pip install sampleapp <insert url here>
And if you are just installing extra packages from PyPI, you need to include --extra-index-url.
But since you specified that it is not able to reach the internet, or if it does not have internet access at all you can try this workaround, you need to download the wheel package to a machine that has internet access then transfer it to the machine without the internet access. There are two ways you can do this, Here is an example of the approach if you only have one package to install:
1. Download a specific package in a machine that has internet access and place it in a newly created folder.
mkdir sample
pip wheel --wheel-dir ./sample pandas
Archive the file by running the following command:
mkdir sample
tar -cvfz packages.tar.gz ./sample
After that transfer the packages.tar.gz to the machine that has no internet access, then run the following command to untar the file and cd to the packages folder:
tar -xzvf packages.tar.gz
cd packages
then install the package.
pip install * -f ./ --no-index
The package should be installed.
But if you have a lot of dependencies, I would recommend that you put every package name in requirements.txt file. Here is an example of the contents of the requirement.txt file:
pandas
django
scikit-learn
sqlalchemy
Then download the packages in the requirements.txt by following this command:
pip wheel --wheel-dir ./sample -r requirements.txt
2. Archive the file by running the same command earlier:
tar -cvfz packages.tar.gz ./sample
After that transfer the packages.tar.gz to the machine that has no internet access, then run the following command earlier to untar the file and cd to the packages folder:
tar -xzvf packages.tar.gz
cd packages
pip install --no-index --find-links=./ -r requirements.txt
All of the packages in the requirements.txt should be installed.
You can also check this thread that will be helpful to your case:
https://stackoverflow.com/questions/36725843/installing-python-packages-without-internet-and-using-s...
Hope this helps!
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |