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
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions doc/source/development/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,15 @@ 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.

**Unix**/**Mac OS**

.. code-block:: none

# 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

Expand All @@ -254,6 +257,29 @@ You'll need to have at least python3.5 installed on your system.
python setup.py build_ext --inplace -j 4
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>`__

.. code-block:: none

# Create a virtual environment
# Use an ENV_DIR of your choice. We'll use ~\virtualenvs\pandas-dev
# Any parent directories should already exist
Copy link
Member

Choose a reason for hiding this comment

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

I'd move this outside of the code block, it'll be easier to read as a paragraph than as code comments.

Also, since you explain the equivalence of $env:USERPROFILE and %USERPROFILE% here, you can just leave one of them below. Will look much cleaner and clearer without duplicating the ocmmands.

Other than that, lgtm

python -m venv ~\virtualenvs\pandas-dev

# Activate the virtualenv
~\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 4
Copy link
Member

Choose a reason for hiding this comment

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

not sure why we had -j 4 initially, but I think it's better -j auto, so all cores are used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At least under Windows you need to use an integer for -j, 4 is a good value IMHO.

Capture

Copy link
Member

Choose a reason for hiding this comment

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

got confused, it's -j 0

python -m pip install -e . --no-build-isolation

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

Expand Down