poetry install doesnt create .env folder inside project folder with Anaconda python 3.9 env - anaconda3

I have anaconda 3.8 on windows 10. I created python3.9 virtual environment and set poetry config virtualenvs.in-project true. But when I do poetry install it doesnt create the .envn folder inside the project. Below is the poetry env info results:
(python39) C:\Users\username\Developer\Packages\test5>poetry env info
Virtualenv
Python: 3.9.6
Implementation: CPython
Path: C:\Users\username\Anaconda3\envs\python39
Valid: True
System
Platform: win32
OS: nt
Python: C:\Users\username\Anaconda3\envs\python39***
However, when deactivate the python39 environment and run poetry install it creates the .envn folder inside project. and the poetry env info results the following:
Virtualenv
Python: 3.9.6
Implementation: CPython
Path: C:\Users\username\Developer\Packages\test2\.venv
Valid: True
System
Platform: win32
OS: nt
Python: C:\Users\username\Anaconda3\envs\python39
how can I make it work in python39 environment?

This is an expected behavior. Whenever poetry detect it's running within a virtual environment it will not create a new one ( Exception: condas "base" environment is not detected as a virtual environment).
To create an in-project venv for python3.9 using conda you can do this:
set the config to virtualenvs.in-project true
without being in a venv run poetry run env use /path/to/python3.9 once
run poetry install
Also have a look into the docs about poetry env use.
(Question and are answer are cross-posted in poetry's issue tracker)

Related

Activation script not found when creating a Python virtual environment

The activation script is not found when creating a Python virtual environment with the command mkvirtualenv of virtualenvwrapper.
After installing the 22.04 Linux Ubuntu version, I noticed that after installing virtualenv and virtualenvwrapper, I'm getting the following error when using the command mkvirtualenv test103 :
ERROR: Environment '/home/paul/.virtualenvs/test103' does not contain an activate script.
I made several research and here is my final .bashrc file update :
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh
export VIRTUALENVWRAPPER_ENV_BIN_DIR=usr/local/bin
Note that if I execute this command:
source /home/paul/.virtualenvs/test103/local/bin/activate
the virtual environment is activated! However, I prefer to use mkvirtualenv name and then workon name without errors.

Equivalent of `python setup.py develop` in poetry

With setuptools, I could use python3 setup.py develop and my development directory could be found by python3 without setting PYTHONPATH or running install. Any change in the current development directory is immediately available without running python3 setup.py develop/install again. This saves quite a lot of time during the development.
Is there a poetry equivalent?
Update There is a feature request https://github.com/python-poetry/poetry/issues/1214
In poetry, the main project is installed as editable by default:
The current project is installed in editable mode by default.
-- Section "Installing dependencies only" of Poetry's documentation
It is also possible to install some dependencies as editable alongside the main project in the same virtual environment. For example:
[tool.poetry.dependencies]
Library = { path = "../Library/", develop = true }

VCPKG_FORCE_SYSTEM_BINARIES Errors when Running vcpkg on raspberry pi

I installed the latest version of cmake and was following some instructions i made to integrate a project that used vcpkg with grpc. After installing vcpkg I try to install package with ./vcpkg install grpc which resulted in the error bellow. The instructions worked on a OSX and Ubuntu but I run into issues with raspberry pi.
I have set tried both 0 and 1 like so $VCPKG_FORCE_SYSTEM_BINARIES=1 but neither option is working. Using ./vcpkg result in a VCPKG_FORCE_SYSTEM_BINARIES error:
pi#raspberrypi:~/vcpkg $ ./vcpkg
Environment variable VCPKG_FORCE_SYSTEM_BINARIES must be set on arm and s390x platforms.
pi#raspberrypi:~/vcpkg $ VCPKG_FORCE_SYSTEM_BINARIES=1
pi#raspberrypi:~/vcpkg $ echo $VCPKG_FORCE_SYSTEM_BINARIES
1
pi#raspberrypi:~/vcpkg $ ./vcpkg
Environment variable VCPKG_FORCE_SYSTEM_BINARIES must be set on arm and s390x platforms.
In bash the environment variable is set with export:
export VCPKG_FORCE_SYSTEM_BINARIES=1
./vcpkg install grpc
The export command can be put in .bashrc to persist this setting.
src: https://github.com/microsoft/vcpkg/issues/14140

cannot activate virtualenv: No such file or directory

I have problem with activating virtualenv.
I'm working on the server and using SSH secure shell.
My final goal is to activate virtualenv and run the latest version of tensorflow
The following is the command lines:
jeonguyoang#vision6:~$ python3 -m venv tfenv
The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.
apt-get install python3-venv
You may need to use sudo with that command. After installing the python3-venv
package, recreate your virtual environment.
jeonguyoang#vision6:~$ source tfenv/bin/activate
-bash: tfenv/bin/activate: No such file or directory
jeonguyoang#vision6:~$ cd tfenv
jeonguyoang#vision6:~/tfenv$ ls
bin include lib lib64 pyvenv.cfg
jeonguyoang#vision6:~/tfenv$ cd bin
jeonguyoang#vision6:~/tfenv/bin$ ls
python python3
captured image of the commands
I think that there is no activate file.
Maybe re-installing virtualenv is the answer, but I cannot interrupt server settings..
Check if you have python 2 versions of pip and python (python-all & python-pip packages). Venv installs both v2 and v3 versions of python & pip (regardless of python version of venv).

Can not access Anaconda/Miniconda environment as virtualenv with pyenv

I'm showing you the steps I use to create a virtualenv based on miniconda based on pyenv-virtualenv docs. Finally you will see that the virtualenv was created but I can't access to it.
1.0. Check my initial pyenv versions:
$ pyenv versions
* system (set by /home/oscar/.python-version)
2.7.9
3.5.1
1.1 Install miniconda:
$ pyenv install miniconda3-4.0.5
$ pyenv versions
* system (set by /home/oscar/.python-version)
2.7.9
3.5.1
miniconda3-4.0.5
1.2. Create the venvtest virtualenv based on miniconda:
$ pyenv virtualenv miniconda3-4.0.5 venvtest
$ pyenv versions
* system (set by /home/oscar/.python-version)
2.7.9
3.5.1
miniconda3-4.0.5
miniconda3-4.0.5/envs/venvtest
venvtest
When I want to check if the virtualenv was created, It doesn't show it. So I can't no access to it :(
$ pyenv virtualenvs
miniconda3-4.0.5 (created from /home/oscar/.pyenv/versions/miniconda3-4.0.5)
$ pyenv activate ... (autocompleting)
--help miniconda3-4.0.5 --unset
Please, I hope you can help me.
https://github.com/yyuu/pyenv-virtualenv/issues/178
A bit late answer. But a similar thing happened to me.
So I used
source /Users/<user_name>/Applications/anaconda3/bin/activate <env_name>
instead of
source activate <env_name>
My recommendation is to not install Miniconda or Anaconda (herein refereed to as *conda) via pyenv. Instead, download the installer from the applicable site and install it as follows.
Eg. I downloaded the installer from the website to ~/Downloads
% cd ~/Downloads
% ls | grep conda
Miniconda3-latest-Linux-x86_64.sh
Run the installer:
% bash Miniconda3-latest-Linux-x86_64.sh
Now most importantly, at the end of the installer when you are prompted Q) Do you wish the installer to initialize Miniconda3 by running conda init? [yes|no], choose no.
Note: If you choose yes, Miniconda or Anaconda will deploy changes into your ~/.bashrc which will start up the *conda environment every time you open a bash session. This will corrupt pyenv.
After the installer is complete, add the following functions* to your ~/.bashrc:
function aconda {
eval "$(${HOME/miniconda3/bin/conda shell.bash hook)"
}
function dconda {
conda deactivate
}
* change the path to conda executable as required.
To launch the *conda environment, open any terminal and type aconda and to deactivate type dconda and that's it.
These instructions are for Linux but should port to Mac easily, not sure about windows though as I don't use it for my development.
I'm new to using the *conda environments and was surprised with the lack of simple instructions so I had to do a bunch of trial and error to get it so PyEnv, which I adore, working correctly. Hopefully this helps some others.
Now that it's 2022, it's time for a new answer...
It appears that the current method for installs of *conda via pyenv is to manage the conda virtual environment with conda's commands.
From the pyenv-virtualenv README:
"You can manage conda environments by conda create as same manner as standard Anaconda/Miniconda installations. To use those environments, you can use pyenv activate and pyenv deactivate... If conda is available, pyenv virtualenv will use it to create environment by conda create." See the Github repo README.md for a command walk-through.