Creating a new environment once virtualenv has been installed - python-3.x

I have successuly installed virtualenv using pip install virtualenv. Then i created a new environment under
(base) C:\Users\xxxxxx\PythonScripts\TwitterTutorial>
using the command virtualenv myenv
then as expected a new environment is created under
C:\Users\xxxx\PythonScripts\TwitterTutorial\myenv
The next step is to activate this environment using this command
(base) C:\Users\xxxx\PythonScripts\TwitterTutorial>.\myenv\Scripts\activate
My issue is that the response is as follows:
(myenv) (base) C:\Users\XXXXXX\PythonScripts\TwitterTutorial>
As you can see, the myenv environment is activated on top of the base one. I found that weird because i expected a response similar to this
(myenv) C:\Users\XXXXXX\PythonScripts\TwitterTutorial>
Maybe the command .\myenv\Scripts\activate is wrong?
On a different note, i have created environments in the past and to activate them i usually do conda activate env and it worked successfully for that particular task (not for this one unfortunately)
Many Thanks for your help

Related

unable to install into conda environment

is there a way to specify for a given python package to install in a given conda env vs. the User's python?
I thought that if I did pip install <package> in a given conda environment, this would make the package accessible in that environment.
If I create a conda environment and install pySankey then do conda list, pySankey won't show but instead be installed in /Users/username/Python/3.7/lib/python/site-packages/
The package installs with "Defaulting to user installation because normal site-packages is not writeable". I looked at other stack posts associated with this, but I'm unclear how to modify ~/.bashrc, since my understanding is that ~/.bashrc is not unique to a conda environment. I also checked the path of the conda environment but there's no local as indicated here.
This has happened to me with a couple different packages (eg these packages do not pip install into the conda environment, other do), I'm using pySankey as an example.
thanks!

Cannot connect to rust kernel from a jupyter server in a conda env

I have been trying to install a Rust kernel for a Jupyter server inside a dedicated conda environment but I get errors.
Slighty adjusting steps from:
https://depth-first.com/articles/2020/09/21/interactive-rust-in-a-repl-and-jupyter-notebook-with-evcxr/
conda create -n rusttest
conda activate rusttest
conda install -c conda-forge rust jupyterlab
conda install -c anaconda cmake -y
cargo install evcxr_jupyter
Add $HOME/.cargo/bin to my PATH variable (export PATH)
evcxr_jupyter --install (here I already see the kernel is installed outside the env)
jupyter lab
The kernel is visible on the dashboard however when I try to start a notebook with it the connection fails and I get:
Error: Failed to find sysroot for Cargo.toml file /tmp/.tmpbZ0Pkw/Cargo.toml. Is rust-src installed?
I have tried manually:
jupyter kernelspec install {MY_PATH_DURING_PKG_INSTALLATION}/Jupyter/kernels/rust --sys-prefix
And I get:
[InstallKernelSpec] Installed kernelspec rust in {MY_PATH}/miniconda3/envs/rusttest/share/jupyter/kernels/rust
Which seems OK (inside the correct conda env) but the error persists.
Is there any way to add a working kernel just to this one jupyter server inside that env?
(I want Rust to be gone when I start jupyter lab from another conda env)
EDIT
After digging into this I think the first thing is to get rust-src installed inside that conda environment... I don't know how...
Solved:
I needed to download https://static.rust-lang.org/dist/2022-05-19/rust-src-1.61.0.tar.gz manually and extract it under the env dir such that XXX/miniconda3/envs/rusttest/lib/rustlib/src/rust exists.

Error while trying to run snakemake in a venv on a protected server

For a project I made a virtual environment (venv) using Python3. I installed all the necessary dependencies using a simple bash script (see picture below) after I activated my venv. (I verified the installed packages using: pip3 list and concluded that every dependency was installed succesfully.)
My project uses snakemake, so I ran this snakemake commando:
snakemake --snakefile Snakefile.py all
I get this error:
I know it has to do something with the venv, because without the venv snakemake runs perfectly. I have read the Snakemake installation documents and it says I have to install conda and make & activate a conda venv. But, I do not have the sudo privileges to download and install conda (I work on a protected server).
What is happening and does someone know a fix?
One possible reason could be the difference in Python versions. What version of Python does the pip3 prepare environment for?
As I can see from the picture provided, the invalid syntax may be because of the version of Python doesn't support f-strings.
Imagine the following two scenarios: when you run Snakemake manually, you use the latest Python3 (e.g. 3.9). But if the pip3 is configured for an older version (e.g. 3.5), you can configure a very different environment for Python3.5 that doesn't support f-strings.

"conda init" prevents anaconda-navigator from working on all but base environment

After running conda init from the terminal I am only able to run from the terminal anaconda-navigator from the base environment of anaconda. I want to make it so that I can run anaconda-navigator from any environment including no environment.
I started down this because conda activate myenv would not work. It recommended running conda init; so I did. Previously I could run anaconda-navigator from any anaconda environment and it would pop up but now if I try from anything but base it doesn't work and I get this error message "anaconda-navigator: command not found". However if I enter conda activate into the terminal to bring on the base environment the command works.
I just got done with a clean install of anaconda3 using the recommended steps https://docs.anaconda.com/anaconda/install/linux/
If I delete what conda init added to my .bashrc and add in
export PATH=/home/yourUserName/anaconda3/bin:$PATH
then anaconda-navigator works again from any environement but conda activate myenv stops working.
FYI: I ran conda config --set auto_activate_base False after installing anaconda3
I expect to be able to run anaconda-navigator from any anaconda environment and to be able to use conda activate myenv. Right now I can do one or the other by modifying my .bashrc

error creating python3 virtualenv for readthedocs

I am trying to use a local instance of readthedocs to build documentation for a project written in python 3. (I already have successfully built documentation for one python 2 project).
When I select the option to set The Python interpreter used to create the virtual environment to CPython3.X in the advanced settings, then the build fails, with the command
python3.5 -mvirtualenv --no-site-packages --no-download /home/user/rtd/checkouts/readthedocs.org/user_builds/project/envs/latest
producing the error /usr/bin/python3.5: No module named virtualenv.
However pip3 install virtualenv yeilds Requirement already satisfied: virtualenv in /usr/local/lib/python2.7/dist-packages. I've tried switching to using conda but am having problems with that. Is there anyway to use virtualenv with the global python 3 installation?
I know from the installation instructions that
you’ll need to install Python 3 with virtualenv in your system as well.
However it is not clear to me what they are saying there. Could someone clarify?

Resources