Windows virtualenv issue - bin created instead of Script - python

I tried to create a virtualenv with Windows 10 cmd, and I followed steps below.
C:\Users\pahkey> cd \
C:\> mkdir venvs
C:\> cd venvs
C:\venvs> python -m venv mysite
C:\venvs>cd C:\venvs\mysite\Scripts
Here, error happens, it says "system cannnot find the file specified".
So I check inside mysite, there was "bin" instead of "Scripts".
As I said, I use Windows, not Linux/Mac.
I tried below,
C:\venvs>cd C:\venvs\mysite\bin
C:\venvs\mysite\bin> activate
it says "'activate is not recognized as an internal or external command, operable program or batch file."
These are my current conditions.
mysite
bin
Anyone knows about this problem please help me...
C:\Users\pahkey> cd \
C:\> mkdir venvs
C:\> cd venvs
C:\venvs> python -m venv mysite
C:\venvs>cd C:\venvs\mysite\Scripts
C:\venvs>cd C:\venvs\mysite\bin
C:\venvs\mysite\bin> activate

Related

I can't install environement XTBApi

I am a trader, I want to use the XTB API to access the account,T try to learn Python I found XTBApi I install it Windows (python3 -m venv env)
but when I enter the command (. \ venv \ Scripts \ activate) it doesn't work: The specified path could not be found.
What do I have to do?
Thanks
How can i convert linux script to windows script :
git clone git#github.com:federico123579/XTBApi.git
cd XTBApi/
python3 -m venv env
. env/bin/activate
pip install .
From what I know of venv, activate is found in bin, try
venv/bin/activate
You've mentioned in the comment XTBApi\env\Scripts\activate.bat being present.
Execute that file because that's written in Windows' scripting language (Batch) instead of Linux/UNIX's scripting language (Bash). Those aren't compatible, nor have the same syntax.
XTBApi\env\Scripts\activate -> Bash (for msys2 or similar things that have Bash interpreter)
XTBApi\env\Scripts\activate.bat -> Batch (for cmd.exe)
There should also be a .ps1 file for Powershell, if you are using it.

Unable to de-activate virtual env in Jupyter notebok python

I already referred this related post but it doesn't help. Please refer the details below
I was learning about python virtual environments and was trying to execute some basic commands.
Though I am able to activate the virtualenv, I am not able to de-activate it.
The jupyter notebbok file is currently in path /home/abcd
Below is what I tried
!mkdir python-virtual-environments
!cd python-virtual-environments
!virtualenv env
!. env/bin/activate # here `source` didn't work. So, I replaced it with `.` and it started working
!. deactivate # doesn't work. I tried `! deactivate` but it doesn't work
I get the below error
**`/bin/sh: 1: .: deactivate: not found`**
I have two questions
a) How to deactivate the virtualenv that I created env? What's the proper command?
b) Why is the env folder created in my present working directory? Shouldn't it be under python-virtual-environments based on mkdir and cd commands ?
How to deactivate the virtualenv that I created env? What's the proper command?
Simply restart the kernel - that should do it. Or, simply do deactivate.
Why is the env folder created in my present working directory? Shouldn't it be under python-virtual-environments based on mkdir and cd commands?
Every time you use the ! command, you are creating a new shell that executes the command -- in other words, when you cd you are going into the folder, but the next command is back in root. Therefore, you can do:
!mkdir python-virtual-environments && cd python-virtual-environments && virtualenv env && source python-virtual-environments/env/bin/activate
It should be mentioned, however, that this does not actually activates the virtualenv inside the Jupyter notebook, as that's simply not how virtualenvs work. Virtual environments will hold the actual Python executables with all the related pip installable packages. Sourcing it via the notebook won't do much unless you are later on calling Python via !python command.
For Windows (tested with Windows 10):
deactivate is in the same folder als your activate script.
So to deactivate also use it with a prepended path: env/scripts/deactivate

When I use virtualenv to create a virtual environment, why the project use it?

In my project, I use virtualenv created the ENV:
(ENV) bora-MBP:testDemo01 ldl$ ls
ENV db.sqlite3 manage.py templates test01 testDemo01
You see I have an active virtual environment of the project.
In one python file of my project:
import six
print(six.PY3) # print True
I checked the python version of my project using, there it shows it uses Python3.
but I cd into the ENV/lib, there only shows python2.7:
(ENV) bora-MBP:testDemo01 ldl$ cd ENV/lib/
(ENV) bora-MBP:lib ldl$ ls
python2.7
there is no python3, this is my first question.
My second question is, why my project will use the ENV virtual environment? where is the configuration I can check?
EDIT-01
In my first question:
I know I'm using python3 in my project now, I can use six.PY3 to check, or other ways, but why I create a virtual environment, there only gets python2.7 directory under the ENV/lib/?
My second question:
we know my project will use the ENV environment to run program, but why? is there any default settings for my project to use this environment(dependencies, packages and so on)? is there any configuration file for us to check(clearly point out my project testDemo01 will use the ENV as run environment)?
For your first question:
Please check python version on your virtual environment using python --version to make sure it is python 3 or not. Check whether you have multiple versions of python using whereis python in the command line.
For your second question:
To make a virtual environment management process easier install virtualenvwrapper pip install virtualenvwrapper-win.
Then you will be able to check and change your ENV directory from 'edit the system environment variables'. Change or create 'WORKON_HOME' variable with your require path.
Based on your EDIT-01:
It seems like you have multiple version of python installed in your machine and virtualenv is using python2.7. Please use virtualenv -p path_of_python3 envname to create virtualenv with python3. You can find path for all python using whereis python in the command line.
You can check your dependencies using pip freeze inside your virtualenv.
First question, python2.7/ under ENV/lib/ is because of the creation virtualenv method, if you create the ENV like this:
virtualenv -p python3 ./ENV
there should be python3.x/ under ENV/lib/.
For the second question:
is there any configuration file for us to check(clearly point out my project testDemo01 will use the ENV as run environment)?
for the source reason, you should check the ENV/bin/active bash file, when you active the virtual env, then the project use that yet:
VIRTUAL_ENV="/Users/aircraft/Desktop/TestPython/Demo/venv"
export VIRTUAL_ENV
_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH
# unset PYTHONHOME if set
if ! [ -z "${PYTHONHOME+_}" ] ; then
_OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
unset PYTHONHOME
fi
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then
_OLD_VIRTUAL_PS1="$PS1"
if [ "x" != x ] ; then
PS1="$PS1"
else
PS1="(`basename \"$VIRTUAL_ENV\"`) $PS1"
fi
export PS1
fi
you see, when you execute the active bash, there will export the VIRTUAL_ENV, and add it into the PATH, and unset PYTHONHOME if set. This is why the project will use the virtualenv.

ubuntu virtual env not found

This is a simple question but I can't figure out what's the problem.
I have created virtual enviroment (in my home folder) by:
$ python -m venv ll_env
Then I have tried to activate it:
$ source ll_env/bin/activate
and I get the message:
bash: ll_env/bin/activate: No such file or directory
However, the files are clearly there.
name#name:~/ll_env$ ls
bin include lib
name#aname:~/ll_env$ cd bin
name#name:~/ll_env/bin$ ls
python python3 python3.6
What might be the problem? I have Anaconda from Continium analytics installed. Can this cause the problem? Thanks.

Pybrain installed but runs only from terminal

Here's the problem: after a lot of struggle I managed to instal pybrain, but it runs only from terminal when I use the command export 'PYTHONPATH=$PYTHONPATH:'. When I try to import modules and write in Python (through anaconda) I get this error 'no module named pybrain'. It's as if Anaconda couldn't see that pybrain is right there. Could it be a problem with the directory?
I don't understand what it means:
"Change into the directory Pybrain directory after either checking out got or downloading and extracting the archive. There you run (possibly as a superuser on Unix systems):
$ python setup.py install"
which I found on 'http://pybrain.org/docs/quickstart/installation.html'
Use the following command to install it properly to Anaconda:
pip install -i https://pypi.binstar.org/pypi/simple pybrain
That should work. The process to find out why is lengthy, and I'll follow up soon.
Proof:
One of the issues could be that it's not permitting you to install this module.
Try this in your PyBrain directory:
sudo python setup.py install
EDIT:
To navigate within terminal to the directory you use the cd - command. Let's say PyBrain is located in your desktop:
$ (this is where you'll be initially on your terminal)
EDIT 2:
To be in your root directory to be able to navigate to any file use the ../ command until you are there (it's appear as a house on your terminal window):
$ cd ../
$ cd ../
Then navigate to the directory:
$ cd desktop/pyBrain
Or in your case:
$ cd anaconda/lib/python3.4/site-packages/pybrain-master
Further documentation about installation can be found here: https://github.com/pybrain/pybrain/wiki/installation
EDIT 3:
Removing Anaconda:
rm -rf ~/anaconda
The rm command will remove the file, and the rf will force it to be deleted (otherwise it might not delete the directory).

Categories

Resources