Has anybody figured out how to use pywin32 in a virtual environment? - pywin32

People have been trying for years to get pywin32 to work inside a virtual environment, and it seems nobody has succeeded yet. At least, all the unanswered questions about how to do it are swamping the few questions that have received answers. I need to have my Python script use COM to communicate with an ActiveX program, and so I need win32com.client.Dispatch(), and so I need pywin32. I've read that pypiwin32 is the currently favored module, but it depends on pywin32.
I can load pywin32 into my registered copy of Python with no trouble, but I want to be able to use a virtual environment based on the 32-bit version of Python 3.8.
So how do I do it? If I need a 64-bit version of Python, I can switch, but I'd rather not.
Here is what happens when I tried it using a venv based on 64-bit Python 3.8 on my Win10 box:
(venv) C:\misc\venv_test\venv\Scripts>python
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
(venv) C:\misc\venv_test\venv\Scripts>pip install pywin32
Collecting pywin32
Could not find a version that satisfies the requirement pywin32 (from versions: )
No matching distribution found for pywin32
(venv) C:\misc\venv_test\venv\Scripts>pip install c:\misc\pywin32-227-cp38-cp38-win32.whl
pywin32-227-cp38-cp38-win32.whl is not a supported wheel on this platform.
(venv) C:\misc\venv_test\venv\Scripts>pip install c:\misc\pywin32-227-cp38-cp38-win_amd64.whl
pywin32-227-cp38-cp38-win_amd64.whl is not a supported wheel on this platform.
And on a venv based on the 32-bit version of Python 3.8:
(venv) T:\Worthington Steel\Scripts Python3\venv\Scripts>python
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 22:39:24) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
(venv) T:\Worthington Steel\Scripts Python3\venv\Scripts>pip install pywin32
Collecting pywin32
Could not find a version that satisfies the requirement pywin32 (from versions: )
No matching distribution found for pywin32
(venv) T:\Worthington Steel\Scripts Python3\venv\Scripts>pip install c:\misc\pywin32-227-cp38-cp38-win32.whl
pywin32-227-cp38-cp38-win32.whl is not a supported wheel on this platform.
(venv) T:\Worthington Steel\Scripts Python3\venv\Scripts>pip install c:\misc\pywin32-227-cp38-cp38-win_amd64.whl
pywin32-227-cp38-cp38-win_amd64.whl is not a supported wheel on this platform.
(venv) T:\Worthington Steel\Scripts Python3\venv\Scripts>

Related

How do I remove python 3.8 when i have both python 3.7 and 3.8 installed on MacOS?

I have a really messy python installation on my mac, need some help.
I installed python3 with Homebrew and it showed that
python 3.7.8 is already installed and up-to-date
But when I run python3 on my terminal, i see,
Python 3.8.3 (default, May 27 2020, 20:53:40)
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
And now i cant install any modules with pip3, it shows,
File "/usr/local/opt/python#3.8/bin/pip3", line 6, in <module>
from pkg_resources import load_entry_point
ModuleNotFoundError: No module named 'pkg_resources'
I would like to remove python 3.8 completely and use 3.7 instead, what should I do?
solution
In the link there is solution about deleting 2.8. I guess deleting python versions does not change version to version. Check that link.

How to install pip3 for a specific python version

I have python3.7 installed but also python3.4. For example:
$ python3
Python 3.4.3 (default, Nov 12 2018, 22:25:49)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
And:
$ python3.7
Python 3.7.0 (default, Jun 28 2018, 00:00:00)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
How can I install packages to python3.7 ? Any pip3 command I use goes to python3.4 and I'm not sure how to install anything for python3.7. Any ideas? Even running something like this doesn't work:
$ python3.7 -m ensurepip --upgrade
/usr/bin/python3.7: No module named ensurepip
Or:
$ sudo python3.7 -m pip install PyMySQL
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
I don't know whether this may be an appropriate solution for you. But this is what I generally follow.
Just install Anaconda in your system and create different environments according to your needs.
For your case create two different environments one for Python 3.4.3 and another for Python 3.7 using the following command
conda create --name py34 python=3.4.3 and
conda create --name py37 python=3.7
//This lines will create two new environments named py34 and py37
You then install libraries according to your needs in the respective environment. Now you can work into each environment without interfering with the libraries of the other environment.
To use anaconda kindly follow Anaconda cheatsheet. You will get everything that you need.
Hope this will help you.
This might help : It addresses the same issue as yours. In short, try
python3.7 -m pip install pip
Here's a reference documentation

How to have python3.6 alongside python3.7 windows 10

I'm trying to install tensorflow onto a Windows PC with Python3.7. However, I'm had errors. From what I can gather this is happening because tensorflow doesn't yet support Python3.7. As a workaround I want to install Python3.6 alongside 3.7 and then install tensorflow to that version. However, I'm new to Windows and
when I call for Python in the terminal I now have
C:\Users\antoi>python
Python 3.6.7 (v3.6.7:6ec5cf24b7, Oct 20 2018, 13:35:33) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
How can I have 3.7 as well as we would have been able on Ubuntu ?
You can just install python 3.6, add it's binary path to the system path and call it as python3.6 (actually the same way it works in ubuntu). You can also explicitly call it with its full path: C:\Program Files\Python3.6\bin\python3.6.exe -m pip install tensorflow.

getting error 'No module named pip3' in spite of pip3 being present

I'm on ubuntu 14.04. Python 3.4 was present already, I additionally installed python 3.6.
Python 3.6 seemingly runs fine:
...:/usr/bin$ python3.6
Python 3.6.3 (default, Oct 6 2017, 00:00:00)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
pip3 also runs fine, but for python 3.6.4 (as expected):
...:/usr/bin$ pip3 -V
pip 9.0.1 from /usr/local/lib/python3.4/dist-packages (python 3.4)
So I tried running pip3 under python 3.6, but no luck:
...:/usr/bin$ python3.6 -m pip3 -V
/usr/bin/python3.6: No module named pip3
When searching I found a couple of suggestioons aroundthat error message, but they were all about pip3 not working at all, which is not my problem.
What am I getting wrong?

ModuleNotFoundError: No module named 'JayDeBeApi3'

I don't understand why Python3 is giving me an module not find error on importing JayDeBeApi3 module.
import JayDeBeApi3
ModuleNotFoundError: No module named 'JayDeBeApi3'
Please below, JayDeBeApi3 is successfully installed
pip3 install JayDeBeApi3
Collecting JayDeBeApi3
Using cached JayDeBeApi3-1.3.2.tar.gz
Requirement already satisfied: py4j in /usr/local/lib/python3.6/site-packages (from JayDeBeApi3)
Installing collected packages: JayDeBeApi3
Running setup.py install for JayDeBeApi3 ... done
Successfully installed JayDeBeApi3-1.3.2
BELOW IS PYTHONPATH SETTING
Python 3.6.0 (default, Nov 27 2017, 11:04:30)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux
Type "help", "copyright", "credits" or "license" for more information.
import sys
print (sys.path)
['', '/usr/local/lib/python36.zip', '/usr/local/lib/python3.6', '/usr/local/lib/python3.6/lib-dynload', '/root/.local/lib/python3.6/site-packages', '/usr/local/lib/python3.6/site-packages']
# locate JayDeBeApi3
usr/local/lib/python3.6/site-packages/JayDeBeApi3-1.3.2-py3.6.egg-info
/usr/local/lib/python3.6/site-packages/JayDeBeApi3-1.3.2-py3.6.egg-info/PKG-INFO
/usr/local/lib/python3.6/site-packages/JayDeBeApi3-1.3.2-py3.6.egg-info/SOURCES.txt
/usr/local/lib/python3.6/site-packages/JayDeBeApi3-1.3.2-py3.6.egg-info/dependency_links.txt
/usr/local/lib/python3.6/site-packages/JayDeBeApi3-1.3.2-py3.6.egg-info/installed-files.txt
/usr/local/lib/python3.6/site-packages/JayDeBeApi3-1.3.2-py3.6.egg-info/requires.txt
/usr/local/lib/python3.6/site-packages/JayDeBeApi3-1.3.2-py3.6.egg-info/top_level.txt
Downloading JayDeBeApi3 1.3 from https://pypi.python.org/pypi/JayDeBeApi3/1.3 and installing it locally resolved the issue for me. Though, I am sure, that's not an actual solution.

Resources