I'm in the middle of switching from VS Code to Atom and I'm trying to set up a virtual environment for my python project.
It was pretty easy to do in VS Code, I'd run the following script and it would automagically start using the new env (with all the required packages) when I'd run the script:
python3 -m venv my_env
source my_env/bin/activate
pip3 install -r requirements.txt
Now I'm trying to set up Hydrogen to work the same way. When I run lines of code inline with Hydrogen, I want them to be run in a virtual environment that has the imported modules I need from a requirements.txt
file.
I was able to install the python3 kernel with the following commands:
python3 -m venv my_environment_name # create a virtual environment
source my_environment_name/bin/activate # activate the virtual environment
python -m pip install ipykernel # install the python kernel (ipykernel) into the virtual environment
python -m ipykernel install
And Atom is able to see it: Screenshot
However, I'm still puzzled as how to install my dependencies into the kernel. And if I do install my dependencies there, I don't want my next python projects to have all those modules in there. I'd love to have the fresh-slate that virtual environments promise.
Any help here would be appreciated. Has anyone had experience setting up a virtual environment that can be used by the Hydrogen package?
Setting Up a Python Environment in Atom Step 1: Checking Your Python Version. To get the most out of Atom your co m puter needs to be running Python 3. To check... Step 2: Download Atom. Go to Atom’s Website and click on download. Step 3: Packages. Now that you have Atom on your computer it’s time ...
Python, Julia and R with Atom + Hydrogen One of the main reasons to use Atom is the Hydrogen package , which is an interactive coding environment that supports Python, R and Julia kernels. Put simply, Hydrogen lets you run code inline and in real time, which is the ideal workflow for rapid developing.
Once we have Anaconda Python installed (or any Python distribution + Jupyter), we can now install Hydrogen itself. In Atom, go to Settings (Ctrl+Comma) and in the Install pane look for hydrogen and install it. Now we’re ready for interactive coding! Create a new file with a.py (or.R or.jl) extension and write some code.
Setting up Atom as a Python IDE [A How To Guide] The guide shows how you can setup and maintain a python friendly development environment from within Atom. In a separate article I (will) show how to setup Microsoft Visual Studio Code in a similar manner. The guide is tested and valid for the latest version of Atom 1.40-40-Python 3.
Ok, after some more experimentation, I was able to connect to a kernel that I had installed my requirements.txt
into.
Here are the steps I took:
python3 -m venv env
source env/bin/activate
# make sure requirements.txt has ipykernel in it
pip3 install -r requirements.txt
python3 -m ipykernel install --user --name=env
Then in Atom, press cmd-shift-p
and find Hydrogen: Update Kernels
.
Or manually Packages->Hydrogen->Update Kernels
After, I was able to use the kernel by doing cmd-shift-p
again and selecting Hydrogen: Start Local Kernel
and selecting env
.
When I would run import statements via Hydrogen (selecting them and pressing cmd-enter
), they would now know what to import! Horray!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With