I am trying to write a script, which starts pgadmin4. The program starts if I run the script python3 web/pgAdmin4.py from its own folder, but that isn't as fast as running a command from $PATH...
I managed to write a shell script based on other answers from different posts, but sadly the virtual environment still doesn't work (I assume).
The shell script:
#!/bin/bash
source ~/pgadmin4/venv/bin/activate
python3 ~/pgadmin4/web/pgAdmin4.py
The output:
If you have followed these installation steps no need to activate the virtual environment. You can call the executable file pgadmin4 under bin directory that will be executed with the pgadmin4 virtual environment:
#!/bin/bash
~/pgadmin4/venv/bin/pgadmin4
The error message you provided indicates that you lack the "flask" module. Please install it through "pip install flask" or "python3 - m pip install flask".
python3 -m pip install flask
Related
Most of you may know OpenAI playground, so I built an function generator app and followed all the instructions but I can't launch it via venv-python. I can actually install the requirements using pip while venv is not active and can launch the site with flask, but when I try to install requirements after activating venv, I get this error;
User#lalec ~
$ cd openai-quickstart-python
User#lalec ~/openai-quickstart-python (master)
$ . venv/Scripts/activate
(venv)
User#lalec ~/openai-quickstart-python (master)
$ pip install -r requirements.txt
Fatal error in launcher: Unable to create process using '"C:\Users\celal\openai-quickstart-python\venv\Scripts\python.exe" "C:\Users\User\openai-quickstart-python\venv\Scripts\pip.exe" install -r requirements.txt': The system cannot find the file specified.
How do I fix this? I added every possible script locations into PATH I thought it would help but no result.
I just realized two directories in the error doesn't match, and "C:\Users\celal\openai-quickstart-python\venv\Scripts\python.exe" actually does not even exist. Maybe that's the problem... How can I change this ??
Sorry if I'm asking dumb questions I'm new to all this... Also, I don't get why I need venv activated while I can just launch it by accessing the directory and type flask run in cmd, would appreciate any answers.
ss of the project's directory
ss of venv/Scripts/
ss of bash screen with errors
The error message suggests that the requirements.txt file can't be read. Check that you definitely can read it and it's in the expected location.
The perferred command for running pip is:
python3 -m pip install -r requirements.txt
This makes sure that you know which python3 binary you're running pip with - some systems have more than one python3 binary in various locations.
You could achieve similar without activating the virtual environment:
./venv/bin/python3 -m pip install -r requirements.txt
I am running
poetry install
from within a python local virtualenv ".venv" . The project is supposed to create an executable hercl that becomes available on the user's path. Two questions:
What options / configuration of I'm not sure if that's supposed to gets installed into the local .venv/bin or in the pyenv shims.
Since poetry reuses / redirects many functions to pip it may be the case that the feature I'm asking about is actually from pip itself. I have not been able to discover from either poetry or pip documentation about this shell script installation. How is this achieved?
Update
After running running pip install outside of the virtualenv it pulls from pypi and creates a bash script ~/.pyenv/shims/my_app .
In my case the my_app is "hercl" and we see this:
$which hercl
~/.pyenv/shims/hercl
Its contents are :
$cat $(which hercl)
#!/usr/bin/env bash
set -e
[ -n "$PYENV_DEBUG" ] && set -x
program="${0##*/}"
export PYENV_ROOT="~/.pyenv"
exec "~/.pyenv/libexec/pyenv" exec "$program" "$#"
Somehow this script is installed when running pip install: I am wondering how pip knows to do this. Is it from the pyproject.ml from poetry ? Is it from a setup.py or setup.cfg associated with pip ?
Anoterh Update #sinoroc has another tack on this: poetry has a scripts section that I did not notice (noobie on that tool).
[tool.poetry.scripts]
hercl = "hercl.hercl:main"
hercl is a command that I was looking for .
But there was also an actual _bash script that would launch hercl that got installed under the shims as part of the virtualenv. i think that script were in the
In a Poetry-based project such executable scripts are defined in the scripts section of pyproject.toml.
If a virtual environment is active when installing the application then the executable is installed in the virtual environment's bin directory. So it is available only while the virtual environment is "active".
I installed Airflow through
pip install apache-airflow
in Conda Promt. It's installed normally, but when i'm trying to launch this command through Conda Prompt:
airflow initdb
It gives me an error that "airflow is not an internal or external command, executable program, or batch file"
How to solve it?
I assume you are running this in windows, you can find more info here: https://stackoverflow.com/a/42510906/840984
In short: Airflow doesn't officially support running on Windows
I am using Git Bash on windows with python 2.7 and I want to work in a virtual environment.
When I type
virtualenv venv
Bash says
bash: virtualenv: command not found
That makes me think virtualenv is not installed, then I try to install virtualenv
pip install virtualenv
But again Bash says
bash: pip: command not found
Then by reading this thread python 2.7: cannot pip on windows "bash: pip: command not found" I find out that it cannot find the pip directory, that maybe is the same reason for which it cannot find virtualenv directory.
So I specify the path of pip and I try again to instal virtualenv
python -m pip install virtualenv
It installs virtualenv but then tells
DEPRECATION: Python 2.7 will reach the end of its life on January 1st,
2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python
2.7.
So I go forward and try to activate my virtualenv by typing
virtualenv venv
and as I expected I get the same error of before
bash: virtualenv: command not found
that I try to solve in the same way I did for pip, by typing
python -m virtualenv venv
and this time bash responds with
$ python -m virtualenv venv New python executable in
C:\Users\Tommaso\DJANGO~1\UDEMYD~1\METAGL~2\venv\Scripts\python.exe
Installing setuptools, pip, wheel... done.
So I guess it created my virtualenv named venv, but in my bash terminal I still get the writing "(master)" at the end of the input line, that I guess it means the virtual environment is not active.
How do I activate it?
Solved!
Here is what I did.
First, by following this SO answer, I found out how to make Git Bash use python 3.7 instead of python 2.7 by default:
I opened the file aliases.sh with Notepad++, located at
C:<path where you installed Git Bash>\etc\profile.d\aliases.sh
Under the paragraph
--show-control-chars: help showing Korean or accented characters
I added these lines indicating where the two versions of python I want to switch are located
alias python2='C:/<installation_path_of_python_2.7>/Python 2.7/python.exe'
alias python='C:/<installation_path_of_python_3.7>/Python 3.7/python.exe'
alias pip='C:/<installation_path_of_python_3.7>/Phyton/Scripts/pip.exe'
alias virtualenv='C:/<installation_path_of_python_3.7>/Phyton/Scripts/virtualenv.exe'
You don't really need the last 2 ones, but it will help you a lot, since it enables Git Bash to call pip, virtualenv and other scripts without writing python -m before the name of the script.
You can check out if you did right by typing
python -i
It should return you the latest python version you specified.
Then if I type
python -m virtualenv venv
It installs the virtual environment in the current directory
To activate that, just type
. venv/scripts/activate
If it works, you should see
(venv)
near to your active input line.
To deactivate it just type
deactivate
I had the same problem before. The solution is to install virtualenv first using pip. Then:
enter virtualenv nameOfTheEnvironment
nameOfTheEnvironment\Scripts\activate
You should see something like:
C:\Users\bamidele\Documents\DjangoProjects>virtualenv venv
created virtual environment CPython3.7.2.final.0-64 in 15334ms
creator CPython3Windows(dest=C:\Users\bamidele\Documents\DjangoProjects\venv, clear=False, global=False)seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_dir=C:\Users\bamidele\AppData\Local\pypa\virtualenv\seed-app-data\v1.0.1)activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
C:\Users\bamidele\Documents\DjangoProjects>venv\Scripts\activate
(venv) C:\Users\bamidele\Documents\DjangoProjects>```
I hope this solves your problem.
In git bash, cd into the virtual environment(venv) directory of your project and use this command
source ./Scripts/activate
to activate virtual environment(venv)
You can go
cd venv\Scripts
path. Then:
Run the command
activate
This run on my Flask project.
I installed python environment by means of commands:
SYS_INSTALL="apt-get install -y"
PIP_INSTALL="pip install"
# Be sure to install setuptools before pip to properly replace easy_install.
$SYS_INSTALL git
$SYS_INSTALL python-dev
$SYS_INSTALL python-setuptools
$SYS_INSTALL python-pip
$PIP_INSTALL virtualenv
also was able to create new virtual environment:
virtualenv .env
However, after running a command like:
. .env/bin/activate
I got
-bash: .env/bin/activate: No such file or directory
After reviewing folder .env/bin I found only one python file. Whole list of files here:
.env/lib:
python2.7
.env/include:
python2.7
.env/bin:
python
What is the issue here?
SOLUTION add --always-copy
virtualenv .env --always-copy
For me it works when I do these steps:
Go to the directory/folder that you want
run virtualenv .env
then run source .env/bin/activate
The accepted answer is incomplete! The suggested code left out your error, but didn't comment on it.
The command . .env/bin/activate would indeed do the same as source on the file activate in the folder .env/bin. In fact, apparently the command "source" is an alias for the command ".", and not the other way around. Note that . here has a space after it, and used differently from the . discussed below (which makes files and folders hidden).
What I notice is that you are calling your folder .env, which is not standard practice. Files and folders preceded by . are made "hidden" by Mac OS X. Standard practice is to call a virtual environment directory env or venv, and to call the virtual environment specification file .env.
So, if your spec file is called .env and your virtual environment directory is called env, you can run either
source env/bin/activate
or
. env/bin/activate.
I had the same issue and the following steps resolved it:
$mkdir annotateNLP
$cd annotateNLP
$python -m venv env
$source env/Scripts/activate
Try these commands in the terminal:
$ mkdir djangoapp
$ cd djangoapp
$ python3 -m venv myvenv
$ source myvenv/bin/activate
You can't go straight into activate command without first creating your virtual environment.
you forgot to include source before activating command is
source env/bin/activate
this question is similar to your's
virtualenv is not compatible with this system or executable
where it creates virtualenv but,python file instead of activate in bin
After going to your virtual environment folder .\Scripts\activate.
In my case, I need to install
sudo apt-get install python3-venv
$ virtualenv env
$ cd env/Scripts/
$ . activate
I was facing this same issue. I uninstalled the virtualenv in Ubuntu and then I installed it again. After this nonsense, it works and now I am able to activate my virtualenv through -$source py3/bin/activate.
If installed venv on a Windows machine, run this command (assuming you are in the working directory that has your venv folder):
In bash terminal: source venv/Scripts/activate
In cmd terminal:
venv\Scripts\activate
where venv is the folder name for your virtual environment
For windows using git bash, run the below command:-
source env\Scripts\activate