How do I install a .whl file in a PyCharm virtualenv?
34,650
Solution 1
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.
Solution 2
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")
Solution 3
My environment is Windows 7 and Python 2.7.12.
Steps to install whl packages into venv:
- Search package on Python Extension Packages for Windows - Christoph Gohlke
- Download package, for example,
mysqlclient‑1.3.13‑cp27‑cp27m‑win32.whl
toC:\Root\python\whls\mysqlclient‑1.3.13‑cp27‑cp27m‑win32.whl
- 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')
Related videos on Youtube
Author by
AidenWebb
Updated on November 27, 2020Comments
-
AidenWebb over 3 years
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?
-
Nils Werner over 7 yearsHave you tried using the PyCharm GUI for installing packages?
-
elethan over 7 yearsRelated (but doesn't seem to be delicate, and has no accepted answer): stackoverflow.com/questions/28663601/…
-
-
AidenWebb over 7 yearsThanks Moses, this did the trick. For Pycharm venv's the path is 'path_to_venv/Scripts/activate.bat
-
Moses Koledoye over 7 years@Awebb I didn't remember it was windows. I updated :)
-
Clément F almost 6 yearsInspired from : stackoverflow.com/questions/12332975/…
-
Comrade Che almost 6 yearspip.main() only available before 10.0.0 version
-
wawawa over 3 yearsI'm able to install the wheel from local dir but couldn't install it from PyCharm, why is that?