Skip to content

DOC: Add instructions how to activate virtual env under windows with pip #29113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 1, 2019
33 changes: 31 additions & 2 deletions doc/source/development/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -238,22 +238,51 @@ Creating a Python environment (pip)
If you aren't using conda for your development environment, follow these instructions.
You'll need to have at least python3.5 installed on your system.

.. code-block:: none
**Unix**/**Mac OS**

.. code-block:: bash

# Create a virtual environment
# Use an ENV_DIR of your choice. We'll use ~/virtualenvs/pandas-dev
# Any parent directories should already exist
python3 -m venv ~/virtualenvs/pandas-dev

# Activate the virtualenv
. ~/virtualenvs/pandas-dev/bin/activate

# Install the build dependencies
python -m pip install -r requirements-dev.txt

# Build and install pandas
python setup.py build_ext --inplace -j 4
python setup.py build_ext --inplace -j 0
python -m pip install -e . --no-build-isolation

**Windows**

Below is a brief overview on how to set-up a virtual environment with Powershell
under Windows. For details please refer to the
`official virtualenv user guide <https://virtualenv.pypa.io/en/stable/userguide/#activate-script>`__

Use an ENV_DIR of your choice. We'll use ~\virtualenvs\pandas-dev where
'~' is the folder pointed to by either $env:USERPROFILE (Powershell) or
%USERPROFILE% (cmd.exe) environment variable. Any parent directories
should already exist.

.. code-block:: powershell

# Create a virtual environment
python -m venv $env:USERPROFILE\virtualenvs\pandas-dev

# Activate the virtualenv. Use activate.bat for cmd.exe
~\virtualenvs\pandas-dev\Scripts\Activate.ps1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that we use $env:USERPROFILE in the previous command, and ~ here. Is this correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is correct. Powershell on its own resolves the ' ~ ' to correctly to the home directory. But I noticed, that if I call python -m venv ~\virtualenvs\pandas-dev, venv won't expand ' ~ ' to your home folder and will create a folder called '~' in your current working directory. Hence I've added $env:USERPROFILE, it is the only place where is really needed, if you are using powershell.

Since ' ~ ' is explained in the now extracted paragraph above, I think the snippet you've quoted can stay as it is.


# Install the build dependencies
python -m pip install -r requirements-dev.txt

# Build and install pandas
python setup.py build_ext --inplace -j 0
python -m pip install -e . --no-build-isolation --no-use-pep517

Creating a branch
-----------------

Expand Down