26

The package manager in Project Interpreter doesn't appear to have any way for me to run a pure pip command so I'm unable to install the wheel as I normally would through command line.

Running through command line installs the wheel on my base python install and not the virtualenv. Help?

AidenWebb
  • 589
  • 2
  • 7
  • 14
  • 1
    Have you tried using the [PyCharm GUI for installing packages](https://www.jetbrains.com/help/pycharm/2016.1/installing-uninstalling-and-upgrading-packages.html)? – Nils Werner Sep 30 '16 at 12:17
  • Related (but doesn't seem to be delicate, and has no accepted answer): http://stackoverflow.com/questions/28663601/regarding-install-scipy-from-pycharm – elethan Sep 30 '16 at 12:19

5 Answers5

15

You can install it from PyCharm's Python console with the pip module :

import pip

def install_whl(path):
    pip.main(['install', path])

install_whl("path/to/file.whl")
Clément F
  • 3,535
  • 6
  • 18
  • 26
8

To install via your command line, and avoid installing on your base Python, you'll have to first activate the virtualenv.

You can do this on POSIX using:

$ source path_to_your_venv/bin/activate

And then for Windows systems:

> path_to_venv\Scripts\activate

You can then install the .whl file with pip install filename.whl while the virtual env has been activated.

Moses Koledoye
  • 77,341
  • 8
  • 133
  • 139
3

My environment is Windows 7 and Python 2.7.12.

Steps to install whl packages into venv:

  1. Search package on Python Extension Packages for Windows - Christoph Gohlke
  2. Download package, for example, mysqlclient‑1.3.13‑cp27‑cp27m‑win32.whl to C:\Root\python\whls\mysqlclient‑1.3.13‑cp27‑cp27m‑win32.whl
  3. Open PyCharm Python Console and execute script below:
import pip
from pip._internal import main as pipmain


def install_whl(path):
    pipmain(['install', path])


install_whl('C:\Root\python\whls\mysqlclient-1.3.13-cp27-cp27m-win32.whl')
userlond
  • 3,632
  • 2
  • 36
  • 53
0

The whl file (opencv package) is in c:\SmartSight\OPCV:

c:\SmartSight\OPCV>pip install opencv_python-3.4.3+contrib-cp36-cp36m-win_amd64.whl
Processing c:\smartsight\opcv\opencv_python-3.4.3+contrib-cp36-cp36m-win_amd64.whl
Installing collected packages: opencv-python
Successfully installed opencv-python-3.4.3+contrib
Farzad Amirjavid
  • 649
  • 5
  • 13
0

Use of pip._internal in PyCharm Python Console generates WARNING message

see: https://github.com/pypa/pip/issues/7498

Move the current entrypoint from pip._internal.main:main to pip._internal.cli.main:main

in PyCharm Python Console use:

import pip
from pip._internal.cli.main import main as pipmain
pipmain(['install', path&packagename])
frank.p
  • 11
  • 1
  • 3