I'm running vscode-server to develop on a remote machine via ssh. This machine has no connection to the internet and runs Python 3.6.5.
I would like to use pylint in vscode for the linting. Problem is that I cannot install it the normal way, since I don't have an internet connection.
What I tried so far:
Use pip download pylint, tar the resulting folder, move it via scp and install it on the remote machine. This didn't work since my local mchine has a different python version from the remote (local: 3.10.x and remote: 3.6.5).
Use the Install on remote: ssh button in the vscode marketplace. This succeeds but when I write code, a message pops up that says: Linter pylint is not installed. When I click on install, it just tries to execute pip install pylint on the remote, which will obviously fail...
Any suggestions on how to proceed here?
This didn't work since my local machine has a different python version from the remote (local: 3.10.x and remote: 3.6.5).
I don't know if it's ultimately going to work, but you can download the latest pylint compatible with python 3.6.5 explicitly, it's pylint 2.13.9 afaik so pip download "pylint==2.13.9".
Problem is that I cannot install it the normal way, since I don't have an internet connection.
I think you can try to upload pylint locally to the server by using SFTP extension.
This extension can syncs your local directory with a remote server directory.
Related
I have a local installation of VirtualBox running on my host machine, which is running Windows 10. I am able to start and run a virtual machine of Ubuntu via the VirtualBox GUI application.
I need to be able to manage the state of that virtual machine using python. As far as I know, the only routes for me to pursue this are:
virtualbox-python library on Github (last active 2020, build failing)
vboxapi library on PyPi (last active 2012, build failing)
virtual-machines-python-manage, which I have not attempted to use since it requires Azure services (which eventually require a paid subscription)
Using this very similar post from June 2017, which was answered by the vboxapi maintainer/virtualbox-python repo hoster at that time, I've surmised that the process should be to easily import the virtualbox or vboxapi libraries.
However, when I run a function of either library, I receive the error No module named 'vboxapi'.
To fix this, I should be able to:
Go to VirtualBox's downloads page (https://www.virtualbox.org/wiki/Downloads) and download the VirtualBox SDK.
Extract the zip file.
Navigate into the subdirectory 'sdk\installer'
Open command prompt in this subdirectory using Administrator mode.
Run python vboxapisetup.py install.
This should install vboxapi, but instead I receive the following error:
C:\Users\PATH_HERE\VirtualBoxSDK-6.1.30-148432\sdk\installer>python vboxapisetup.py install
Cleaning COM cache at C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\Lib\site-packages\win32com\gen_py and C:\Users\USER_HERE\AppData\Local\Temp\gen_py
running install
running build
running build_py
copying vboxapi\__init__.py -> build\lib\vboxapi
running install_lib
creating C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\Lib\site-packages\vboxapi
error: could not create 'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2544.0_x64__qbz5n2kfra8p0\Lib\site-packages\vboxapi': Access is denied
Is this a Path error? Am I overlooking something simple in environmental variables?
This post for the same problem on a ubuntu host machine suggests running the following commands:
export VBOX_INSTALL_PATH=$(which VirtualBox)
sudo -E python vboxapisetup.py install
Is there a windows equivalent method I can try here?
So I was never able to directly run any sort of VirtualBox management software from within python: none of the libraries listed worked for me.
Instead, what I ended up doing was execute bash shell scripts that called VBoxManage and each subsequent command needed. I then had to pipe the results (text output to the terminal from VBoxManage) back into Python and parse the text.
I am filling in for someone while they are on vacation and I am new to python. I've been asked to install several packages in a virtual environment. The big catch is the server cannot be on a public net so I will be downloading the software on a different server and copying it to the server where the researcher will be working.
I found another thread "Install Virtualenv without internet connectivity" at Install Virtualenv without internet connectivity, but that doesn't fit the situation I am in - it looks like they can start from a server on the net to complete their installs and want to share that virtualenv to other systems in a lab environment that may not have Internet connectivity.
Another thread "python: How to create virtualenv without internet connection" at python: How to create virtualenv without internet connection, is similar but it looks like they already have virtualenv installed. I don't find virtualenv installed here.
This Windows Server 2016 system is locked down where I cannot copy and paste the commands I ran to provide the information below, so forgive any typos in the hastily written message. I found the python version installed by:
python --version
Python 3.6.2rc1
I have not been able to find an installer to download for virtualenv. Do I need to download the Python installer again, re-run it and select additional options?
Thank you for any help you are able to provide.
edited to add:
Based on feedback, I changed the command (in an administrative command window) to
python -m venv [path] and I have been able to make some progress.
I have the ability to download gz, whl or other files and move them to this server to run them there, but this server cannot be put online to download the installers directly nor can it connect to a repo to download dependencies. I cannot set up the environment on a different machine that has connectivity and share it without violating the security requirements. Thank you for the link to the Python Package Offline Installation thread - I think I was so narrowly focused on the virtual environment that I missed that post.
You're using Python 3.6, which means venv is included and pip can be bootstrapped if necessary. Creating a venv does not need internet access:
python3 -m venv .venv --prompt=myvenv
Installing pip does not require internet access:
python3 -m ensurepip
Installing a package from a local file does not require internet access:
python3 -m pip install --no-index --disable-pip-version-check ./mydist.tar.gz
Should you have more than one package to install (for example, if mydist has dependencies) you may specify a local directory as your --index-url instead of the index defaulting to PyPI.
A solution for people on older versions of Python is covered here.
I need to deploy python application to a no internet server.
I have created a virtual environment on my host machine which uses Ubuntu. This contains python script with a variety of non-standard libraries. I have used option --relocatable to make the links relative.
I have copied over the environment to my client machine which uses RedHat and has no access to the internet.
After activating it using source my_project/bin/activate the environment does not seem to be working - the python used is standard system one and the libraries don't work.
How can the virtual environment be deployed on a different server?
Edit: this is normally done through the creation of requirement.txt file and then using pip to install the libraries on the target machine, however in this case it's not possible as the machine is offline.
For anyone dealing with the same problem:
The quickest way for me was to:
Create a VirtualBox with the target system on the internet machine
Download wheel files using pip download
Migrate to the target machine
Install with pip install --no-index --find-links pip_libs/ requests
What error is shown when u try to activate it, Make sure the python version and environment PATH are consistent with the ones on the previous system.
I wish to connect to a Linux machine by ssh (from my code) and run some code that is using python libraries that are not installed on the remote machine, what would be the best way to do so?
using a call like this:
cat main.py | ssh user#server python -
will run main.py on the server, but wont help me with the dependencies, is there a way to somehow 'compile' the relevant libraries and have them sent over just for the running my code?
I wish to avoid installing the libraries on the remote machine if possible
Try virtualenv:
pip install virtualenv
then use
virtualenv venv
to create a seperated python environment in current path(in folder venv).
Instead of installing multiple packages in default python path, virtualenv needs only one package installed.
We have two linux servers, one is on private network which does not have internet access. The other is on public network which has internet access. Both the servers run the same RHEL-5 OS.
On as server which has internet access, I have installed python under my home directory as non-root user. Then I used pip to install other packages, pip also resolves dependencies and install the required dependencies.
How I can relocate this python to a server which does not have root access ? Also I want to relocate it as root under different directory ?
Why I want to do this ? Since the private server does not have internet access pip won't work for installing 100s of modules and there dependencies. Since the servers are running the same OS release, is there any easy way to relocate python installed on one server to another server though in a different directory ?
If possible, I'd try to go through the front door and actually install the packages on the other server. Cloning of all packages should in principle be equivalent to the following:
On the first machine (with Internet access and installed packages):
mkdir /tmp/pypackages
pip install -r <(pip freeze) -d /tmp/pypackages
On the second machine:
Copy the packages to /tmp/pypackages
Install them:
cd /tmp/pypackages
pip install *
(either as root or as a regular user).
Note that when I try to run the first set of commands on my machine, I get some errors which I blame on the fact that not all of the packages shown by pip freeze were actually installed with pip. You may need to filter that list as well. It'll probably be easier to save the output of pip freeze to a file and edit it.
P.S. python itself can also be downloaded, transferred, and installed locally by means of the system package manager.