I have installed both virtualenv and pywin32 on my Windows 7 64-bit laptop, and each of them seems to work, but not with each other.
More specifically, if a virtualenv is active, then running import win32com.client in a python interactive shell fails with No module named win32com.client. The same expression succeeds, however, if no virtualenv is active.
When I try to install pywin32 with pip (which is how I normally install modules when a virtualenv is active), I get the error:
Could not find any downloads that satisfy the requirement pywin32
No distributions at all found for pywin32
...even though pywin32 is one of the modules listed in the output of
pip search pywin32
Therefore, to install pywin32 at all I had to install it using an *.exe installer downloaded from SourceForge.
Is there any way to install pywin32 within a virtualenv?
UPDATE 2016
There is now a version of pywin32 on PyPI that can be installed with pip. It is called pypiwin32, and it installs the package using the binary wheel format.
https://pypi.python.org/pypi/pypiwin32
pip install pypiwin32
That will work in a virtualenv, or with tox, etc.
Below this line is my previous old answer. That is now outdated information.
OLD ANSWER - OUTDATED. Modern versions of virtualenv default to --no-site-packages. That means that not having access to global site-packages is now the default behavior.
Sadly, (as of July 2014) you can not pip install pywin32 in to your virtualenv. (here's the bug report)
If you want to get pywin32 running inside a virtualenv, activate the virtualenv and use easy_install and the pywin32 installer exe file. For example
easy_install "C:\Path\To\Downloads\pywin32-219.win32-py3.4.exe"
Related question
Try this:
Download directly
Enable your virtualenv
pip install --no-index --find-links:/local/dir/ SomePackage
Check out #8 on pip-installer.org (sorry no permalink)/
Create a virtualenv and activate it:
cd c:\Users\ernesto.luzon
virtualenv --no-site-packages py351env
py351env\Scripts\activate
From here, you have two options:
Download pywin32 from sourceforge project:
http://sourceforge.net/projects/pywin32/files/pywin32/
Download pywin32 from unofficial (but very helpful) binary site:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pywin32
Make sure you download the correct version for the Python Interpreter installed in your environment, otherwise you will encounter ImportError: DLL load failed: %1 is not a valid Win32 application later.
If you downloaded from sourceforge, install it using easy_install:
(py351env) C:\Users\ernesto.luzon\Downloads>easy_install pywin32-220.win-amd64-py3.5.exe
If you downloaded from gohlke, install it using pip:
(py351env) C:\Users\ernesto.luzon\Downloads>pip install pywin32-220-cp35-none-win_amd64.whl
In case you encounter ImportError: DLL load failed: The specified module could not be found error later on, you need these additional steps:
Run the post install script:
(py351env) C:\Users\ernesto.luzon>python py351env\Scripts\pywin32_postinstall.py -install
Copied pythoncom35.dll to C:\Users\ernesto.luzon\py351env\pythoncom35.dll
Copied pywintypes35.dll to C:\Users\ernesto.luzon\py351env\pywintypes35.dll
....
Notice where it copied the 'pythoncom35.dll' and 'pywintypes35.dll' files. You need to move these files to the folder:
C:\Users\ernesto.luzon\py351env\Lib\site-packages\win32
Related
I've installed a module named rauth through terminal with pip3 install rauth command but when I import the module and run the code on Visual Studio Code with python3 interpreter, it gives ModuleNotFoundError: No module named 'rauth' error. But it is indeed installed and I can use it in Anaconda. The package file is stored here.
/Users/puffedricecracker/anaconda3/lib/python3.7/site-packages/rauth
And it seems like all my pip installed packages are stored in that path, but those are imported outside Anaconda with no problem. Tried several other commands as google search suggested.
• pip install instead of pip3 install
• python -m pip install
• python3 -m pip install
Let me know if there is any other information needed to be specified.
this is due to the module is installed into site-packages in Anaconda but not Visual Studio. Can you check if the module exists in Visual Studio folder? Another way to test it is to open Python IDLE and run the import, it should also return an error.
I don't know if this could be an universal solution but there was a way to set where to install a package using pip.
In python shell, find where your python modules usually go. It seemed like most of pip installed packages were installed in the second path so I chose that.
>>> import re
>>> print(re.__file__)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/re.py
>>> import sqlalchemy
>>> print(sqlalchemy.__file__)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sqlalchemy/__init__.py
Uninstall the package using pip uninstall packagename
Reinstall with a path name.
pip install packagename -t /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
(In fact, just copy pasting package files (in my case, they were rauth, rauth-0.7.3.dist-info) from anaconda package path in the post worked.)
Trying to install a package on Windows fails, as it requires a site.cfg file to contain the path of a library.
It looks like pip extracts packages to c:\users\[username]\appdata\local\temp\pip-install-[random string]\ during installation and deletes after installation (successful or not), so I can't "hot-edit" it.
Can I make pip wait for me before installing?
Can I make pip download and unpack the package and afterwards tell it to install a package from a directory rather than a package name or URL?
Feel free to comment alternative solutions for installing scikits.audiolab on Windows (demands sndfile to be defined in site.cfg).
Does not work on wheels (see #hoefling comment)
Download package from url (pip tells you the url when you do pip install <package_name>)
Untar the file and do your modifications
Then do pip install <path_of_package>
On Windows, open up Anaconda Prompt and type in the following:
pip install json2xml
No complaints from pip for doing this (replace json2xml with your favorite package, I guess). Then, open up Jupyter QTConsole, and try:
import json2xml
The result is an ImportError: No module named 'json2xml'. The package installed (after checking pip list), but nothing recognizes it. There is no system pip (this is Windows, after all); only Anaconda's pip is being used.
What's going on?
I hope this will help, it worked for me.
When you use pip to install a package, by default it will go to your python site-packages.
i. e.
C:\Users\YOUR-USER-NAME\AppData\Local\Programs\Python\Python37-32\Lib\site-packages
From here, you can copy the downloaded packages, then navigate and paste them into your Anaconda site-packages directory.
i. e.
C:\Anaconda\Lib\site-packages
That should solve the issue.
From How do I find the location of my Python site-packages directory? , you can enter
python -m site
to print your python package location(s). In my case, I have Anaconda for Windows and do not have a directory C:\Users\YOUR-USER-NAME\AppData\Local\Programs\Python\Python37-32\Lib\site-packages but did find my package installed with pip was in C:\Users\YOUR-USER-NAME\AppData\Local\Continuum\anaconda3\Lib\site-packages\ . This may be due to adding Anaconda to PATH.
I have Python 2.7.11 installed on my machine which to my understanding should come with pip, however when I check the C:\Python27\Tools\Scripts\ directory there is no pip.exe present.
I have tried completely removing and reinstalling Python 2.7.11 without success. Running the installer pip is set to be installed, but after the install pip is nowhere to be found.
I also have Python 3.4 installed which has pip as expected. Any thoughts?
I encountered the same problem - pip not installed - with python-2.7.16, Win10, installing for 'all users'. It was resolved when I allowed the MSI installer to target the default location (C:\Python27) rather than changing it to under Program Files (x86). I've no clue why this changed anything.
python2.7.11 should install pip into c:\python27\scripts, you can take a look here
I used https://pip.pypa.io/en/stable/installing/ to make it install. Odd that an outside body has to make a tool to get pip to install. There is no mention of pip.pypa.io on the Python web site.
Although I got error messages, it did install, so check carefully.
You also may see a message suggesting that you upgrade to pip 9.0 with the command 'pip install --upgrade.' I highly recommend that.
Also, make sure you are in the directory where pip.exe is located when you run the commands. They don't tell you that, because they assume you know that, but we're not all geeks.
For people who are running into this issue, I have a Windows 10 x86 dev box that I use for exploit development, Python 2.7 was installed due to Immunity Debugger, this install did not include the new SSL package and did not include "pip".
There was no "C:\Python27\Scripts" folder which included pip. I did have a "C:\Python27\Tools\Scripts" folder which did not have pip installed.
I tired to install pip as suggested but did not work. Best way is to uninstall Python and install newest version, currently mine is 2.7.15 which came with pip as an option. This is what solved my issue, any older version of Python will need upgraded to support the SSL packages. You will receive the same errors when you try to install pip on an older version.
If you have reinstalled Python which included the SSL package and it still does not have pip, trying installing pip this way:
1. curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
2. python get-pip.py
https://pip.pypa.io/en/stable/installing/
This should work if you have a newer version of Python.
Once you have installed pip or newer version of python, go to "C:\Python27\Scripts" and you should see pip.exe.
I have installed "python-2.7.16" in my windows 10 PC. PIP is installed under "C:\Python27\Scripts". One can add the "C:\Python27\Scripts" path to environment variable and then access pip command from command prompt.
To add the path in environment variable:
Control Panel\System and Security\System --> Advanced System Settings --> Advanced --> enviroment variables --> under system variable --> Path(variable name)
Had the issue where no matter which version of python 2.7 I installed on windows 10 there was no pip.exe generated in the "Scripts" folder.
I solved it by ensuring that that MSI Installer file had Admin privileges before installing
if pip is not installed you can use easy_install.exe to install pip and other modules
you can find easy install in
python -m easy_install pip
I had the same issue:
Installed Python 27
Tried to use pip, but failed with unrecognized command error
Checked installation: no "C:\Python27\Scripts", only "C:\Python27\Tools\Scripts"
This issue happens only on some versions of Windows.
HOW TO FIX IT:
Uninstall Python 27
Reinstall Python 27, but unselect "pip" feature
Check installation: no "C:\Python27\Scripts" as expected
Start the installer again and use "Change Python"
Set "pip" and "Add Python.exe to Path" features to be installed
Check installation: "C:\Python27\Scripts" is now correctly present
So for some unknown reason, pip is not correctly installed on some versions of Windows if it is installed during default Python 27 setup. To fix this issue, pip must be installed afterwards using the "Change Python" setup.
I meet the same issue when install Python 2.7.9. The installer does not come with pip.
Solution:
Install newer python2 x86 version: https://www.python.org/downloads/release/python-2718/
Then pip is located at C:\Python27\Scripts\pip.exe
It happens on windows as you should have admin rights to install anything on disk C.
I have the same issue Scripts folder was not installed. I would sugest to instal it on disk D.
I've installed python 3.4 on win7. I need faker module to be installed to run the script.
error:
from faker import Factory
ImportError: No module named 'faker'.
I've downloaded few zip's with faker, but unfortunately have no idea how to install it.
Please give simple instructions, how to make it work.(on windows)
Since you have downloaded the zip source from https://github.com/joke2k/faker according to your comments , you can also do the following after changing to the directory where you have setup.py -
python setup.py install
According to the github page itself, to install using pip do -
pip install fake-factory
Use the Python package tool pip.
Open a command prompt and do
pip install fake-factory
or
python -m pip install fake-factory
See the documentation for more information.