Accessing host Python Virtual Environment from a Singularity container - virtualenv

I have a Singularity container with many tools along with Python and Jupyter installed in it. But I want to access the external virtual environments I have created for python while using the other tools in Singularity. The reason being I am experimenting with different python packages which cannot be installed into Singularity container without 'sudo' privileges. And I cannot install the other tools on my host machine due to sudo privileges.
I am able to activate the virtual environment but not able to use it: Get this error when I run pip command or Jupyter lab.
bash: /home/username/virtual-env/bin/pip: /home/username/virtual-env/bin/python: bad interpreter: No such file or directory
I want to run Jupyter lab from the virtual environment which is run from the Singularity container.

Related

Unable to activate Python Virtual Env on compute in VS code

I have two computers, both running VS Code.
I was able to get the virtual environment running on one computer without problem running
python -m venv virtual_env
virtual_env\Scripts\activate
This machine only has Python3 installed and I ran that in a Python terminal in VS code.
On the second machine, it has both Python 3 and Python2 installed. I have tried to set everything up identically between them, but when I run the same code, it fails.
When I run
python -m venv virtual_env
it returns either "No module named venv" (and it's running that in Python 2.7 despite the interpreter being set to 3.8)
When I run
python3 -m venv virtual_env
it says "The system cannot find the file specified".
The directory does appear in the explorer of Machine #2, but in the "Scripts" directory, there does not exist an "activate" file (like there is in Machine #1).
Not sure how to continue troubleshooting this.

PowerShell Opening File instead of Running When in Python Virtual Environment

I am using Python 3.9.9 (installed via MSYS2) and Windows PowerShell on Windows 10 64-bit. I am trying to learn more about Python's virtual environment.
I was able to initialize and activate virtual environment using the respective commands in PowerShell.
python3 -m venv .venv
.\.venv\bin\Activate.ps1
I notice that before activating the virtual environment, python --version would work as expected and output the Python version installed. However, once virtual environment has been activated, the same command would prompt Windows to open a file (window below would pop up).
Window's reaction when in virtual environment
I know the virtual environment was activated because I could see (.venv) being displayed.
Is this expected behavior? What should I do for python commands to still work in virtual environments? Thank you for your help!

How to get the list of the python virtual environments installed on a linux server

I am new to linux environments. I have a linux server on which I have installed python3 in some virtual environment (but I no longer remember the name of the virtual environment). I know that if I were using anaconda on a windows computer, I would do the following to get the virtual environment names.
conda info --envs
The question is how do I get the list of all the virtual environments on my linux server and the path to those environments? In particular, I want a link to the bin folder containing my python3 so that I can activate my virtual environment.
Assuming you have created the virtual environments with the python pip install virtualenv command, run the command
$locate activate
It will list down all the folders having 'activate' in it. Among those you can find the virtual environment folders you created. Remember, the virtual env folders are of this form your_env_name/bin/activate under the parent folder where it was created.

jupyterhub: command not found

I am trying to run the jupyterhub locally on Ubuntu 16.04; however, I cannot seem to run the jupyterhub command on the terminal, and I get the command not found error. I have installed jupyterhub by running the following commands:
sudo npm install -g configurable-http-proxy
pip3 install jupyterhub
pip3 install --upgrade notebook
All of the above packages install successfully. My PATH variable in /etc/environment has been set as follows:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/root/bin"
You need to start a Jupyter service, if you create environments with anaconda you can use them later inside the jupyter as kernels, so you can have a variety of library environments as you like.
There are also other functions to give resource guarantee or limits, or initial folders for your hub.
You can edit all this in your jupyterhub_config.py file.
I leave you here my github with a complete guide for the configuration and installation.
Github/Jupyter
If you can first install Anaconda.
Then install the configurable proxy.
Run commands -
conda install -c conda-forge jupyterhub # installs jupyterhub and proxy
conda install notebook # needed if running the notebook servers locally
Now try jupyterhub

Setting up Vagrant Windows

I am new to vagrant and I keep getting this error.
How can I properly run vagrant up so that I can continue with the setup process?
so once you have Vagrant and VirtualBox installed, the next steps are to create a Vagrantfile which basically is the configuration file for the VM you will build. It contains box information as well as network, sync folder and any provisioning you'll do on the VM.
for example, if you want to create an ubuntu VM:
$ vagrant init <ubuntu/wily64>
$ vagrant up
The first command (vagrant init) might take some time as it will download a VM from internet but you only run it once. then vagrant up will boot the VM