How do I install web2py in a virtualenv in Windows 7? - python

I'm new to Python and I'm trying to install web2py in a virtualenv. I'm running a 32 bit python 2.7.3 installation on a 64 bit Windows 7.
From what I read, this should be the process:
install virtualenv (done)
create the virtualenv (done)
install pywin32 in that env (I've read it needs to be installed before the web2py installation)
install web2py in that env
First and foremost: is that right? If so, then...
I tried installing pywin32 through
'''easy_install pywin32-218.win32-py2.7.exe'''
It went fine. Then, I checked the virtual environment's site-packages for a pywin32 folder and it was there, but I couldn't import it into python ('''ther's no module pywin32'''). The environment was definitely active (I double-checked).
As a test, without using virtualenv, I double-click-installed the pywin32 binary (downloaded the 32 bit version for python 2.7 -- pywin32-218.win32-py2.7.exe) but got an error at the end:
'''close failed in file object destructor:
sys.excepthook is missing
lost sys.stderr'''
I downloaded the file again (could be corrupted), tried installing it again but got the same result.
Could anybody guide me or point me to a step-by-step install of pywin32 (if necessary) and then web2py for windows 7? I'd really appreciate it.

its a bug: http://sourceforge.net/tracker/?func=detail&aid=3402824&group_id=78018&atid=551954,
workaround here : http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/rev/a64d8ac23e61
similar to this: Error installing and running pywin32 2.7

In my experience, the command easy_install pywin32-218.win32-py2.7.exe under an active virtualenv works fine.
To test the installation of pywin32, from python you can try:
from win32api import GetVersionEx
print GetVersionEx()
Obtaining something similar to (windows major version, minor version, build number, platform id, additional informations):
(6, 1, 7601, 2, 'Service Pack 1')
You cannot import module pywin32 because it doesn't exist.
After the installation of pywin32, you can install web2py under the active virtualenv (I tested it until to opening the admin interface, no guarantee after this :-):
download the source code from http://www.web2py.com/init/default/download
unzip it to ...\virtualenvdir\Lib\site-packages\ (obtaining: ...\virtualenvdir\Lib\site-packages\web2py\...)
cd to ...\virtualenvdir\Lib\site-packages\web2py
start the web2py server: python web2py.py
At the date, I couldn't install web2py using pip. First of all, it grabs an old version of web2py from PyPy. When I tryed to use this version of web2py I got an error ImportError: No module named .... The same using pip on a copy of the web2py source file.

Related

django OSError: no library called "cairo" was found on windows

When I run the Django server, I see this problem !!
OSError: no library called "cairo" was found
no library called "libcairo-2" was found
cannot load library 'libcairo.so': error 0x7e
cannot load library 'libcairo.2.dylib': error 0x
cannot load library 'libcairo-2.dll': error 0x7e
Installing GTK+ didn't work for me.
I solved this problem using UniConverter2.0.
My environments is
Python 3.7
Windows 10 x64
Install uniconvertor-2.0rc4-win64_headless.msi,
Find the "dll" sub-directory under the UniConverter installation path.(In my case, C:\Program Files\UniConvertor-2.0rc4\dlls)
Add this "dll" path to the system path.
Close VSCode and reopen the project.
Try to run the server again.
Enjoy!
WeasyPrint needs the Pango, cairo and GDK-PixBuf libraries. They are part of GTK+ (formerly known as GIMP Toolkit), and must be installed separately.
After installing GTK+ libraries, do :
python -m weasyprint http://weasyprint.org weasyprint.pdf
Starting from Python 3.8, dll's need to be added separately.
Added GTK+, MSYS2, Visual Studio C Compiler and Uniconverter. But, nothing seemed to work.
Finally, got it working after putting the script for calling add_dll_directory.
import os
def set_dll_search_path():
# Python 3.8 no longer searches for DLLs in PATH, so we have to add
# everything in PATH manually. Note that unlike PATH add_dll_directory
# has no defined order, so if there are two cairo DLLs in PATH we
# might get a random one.
if os.name != "nt" or not hasattr(os, "add_dll_directory"):
return
for p in os.environ.get("PATH", "").split(os.pathsep):
try:
os.add_dll_directory(p)
except OSError:
pass
set_dll_search_path()
Source: PyCairo Windows Python3.8 Import Issue
See the solution here:
https://www.programmersought.com/article/47674569357/
You will need to add a path if not added after installations:
C:\Program Files\GTK3-Runtime Win64\bin
I have been solving it many times this way.
If you are using a lightweight Linux Docker Image, it may not include GTK as said above, then, you can include it by adding in your Dockerfile
RUN apt-get update -y
RUN apt-get install python3-cffi python3-brotli libpango-1.0-0 libharfbuzz0b libpangoft2-1.0-0 libgtk-3-dev gcc -y
Where all those packages are recommended to be installed by weasyprint and GCC has the GTK.
Ok I figure this out. you can have a 64 bit version of python that doesn't work. What I have found to work and this could change is the installing the 64 bit version of python from python's website, not from the Microsoft store!
remove any version of python you have installed
download https://www.python.org/ftp/python/3.8.10/python-3.8.10-amd64.exe
install
download and install https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer/releases
exact link is https://github.com/tschoonj/GTK-for-Windows-Runtime-Environment-Installer/releases/download/2021-04-29/gtk3-runtime-3.24.29-2021-04-29-ts-win64.exe
note that link is from https://doc.courtbouillon.org/weasyprint/stable/first_steps.html#windows
add bin folder from that (sorry it was somebody else's machine, I use Ubuntu) in your environment path.
run through the first steps on weasyprint and you should be good to go!
Might be a bit late, but I just encoutered the same issue and:
Start here: https://weasyprint.readthedocs.io/en/stable/install.html#windows. Where you will find the links for the GTK Pack that contains the required DLLs.
In my case, I have a 64bit Python, so i use: "Download and run the latest gtk3-runtime-x.x.x-x-x-x-ts-win64.exe"
I did not change the installation directory
Once the installation is completed. I added the path to my variable paths.
I restarted the terminal, made sure I could locate the DLLs with : WHERE libcairo-2.dll. This retured C:\Program Files\GTK3-Runtime Win64\bin\libcairo-2.dll
Then I run python -m weasyprint http://weasyprint.org weasyprint.pdf
and got a few WARNINGs but they are just warnings :)
I have faced same error as well
I haved installed gtk as followed as gtk install in windows
Nothing worked
After that :
python -m pip install pycairo
solved the problem for me
Try this: https://cairocffi.readthedocs.io/en/stable/overview.html#installing-cairo-on-windows
And maybe this will work to: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pycairo
Best option is instal cairocffi trough pipwin
pip install pipwin
pipwin install cairocffi

zlib module issue for local user

My requirement is to install NodeJS using sources (v8.9.4) for a local user (no root access) on Oracle Linux. When I ran the 'configure' and 'make install' it complained that the Python version was not 2.7.
Since there was no root access and I could not upgrade Python, I installed Python for the local user with the steps below.
I downloaded the sources (Python-2.7.11) and ran the configure (with --prefix option) and 'make install'.
Updated the PATH and PYTHONPATH variables to use this version of Python for this user.
Now, when I try to configure NodeJS again, it does not complain about Python 2.7 any more but now says:
File "tools/compress_json.py", line 6, in <module>
import zlib
ImportError: No module named zlib
When I checked if zlib was on the system with 'yum list installed zlib', I see
zlib.i386 1.2.3-4.el5 installed
zlib.x86_64 1.2.3-4.el5 installed
I now do not know
how the local python version can use this zlib module (or)
how/if zlib module needs to be configured into python (or)
if Python has to be installed again with some configuration for getting the zlib module.
I've searched on google and tried a few, but there was nothing conclusive that could help.

Fatal error in launcher: Unable to create process using '"' in python

I had python 2.7 before and then I installed python 3.4.The OS is windows 10
I have renamed
C:\python27\python.exe to python2.exe (when I run python2 --version it shows correct version)
and
C:\python34\python.exe to python3.exe (when I run python3 --version it shows correct version)
I have set the path variable manually and there is no space etc.
I was trying to create a virtual environment and assign python34 to this new environment.
I was going through this SO reference -- Using VirtualEnv with multiple Python versions on windows
prompt>> virtualenv -p c:\Python34\python3.exe casenv
But I got an error--
Fatal error in launcher: Unable to create process using '"'
Do I need to install virtualenv again for python34 or somewhere I need to set virtualenv path for each python installation.
Any help is highly welcomed.
In my case, i had installed python 3.6 and uninstalled python 2.7 when i got this error.
Completely deleting the C:\Python2.7 directory did the trick.
This error is usually caused because of python directory of different versions stored at same location.
i.e in my case I was using python 3.5.X for development and when I updated to 3.7.6 I got this error.
People on internet suggest that it is because of pip but main cause is 2 or more python directory.
The following steps should fix it:
Uninstall previous python version (or use virtual environment if you want to play with multiple python version)
Delete the python directory you are not using (as it causes confusion for terminal to understand which python path it should pick to execute the command)
and this should fix the error of
fatal error in launcher unable to create process using ' '
Pip version: 10.0.0
Python version: 3.6.5 64 bit
Operating system: Windows 7 Ultimate, Service Pack 1, 64-bit
Description:
After upgrading pip to the version 10.0.0 (from Pycharm, that is using pip as a package) any attempts to start updated pip cause an error:
Fatal error in launcher: Unable to create process using '""c:\program files\python 3.6\python.exe" "C:\Program Files\Python 3.6\Scripts\pip.EXE"'
Command python -m pip works as expected.
I found text "Fatal error in launcher" only in executables:
src\pip_vendor\distlib\t32.exe
src\pip_vendor\distlib\t64.exe
and in the pip.exe itself.
After
python -m pip uninstall pip
easy_install.exe pip
error disappeared.
It is interesting, that initially pip.exe had almost the same size as t64.exe, now it significantly shorter.
If someone came after installing a newer version like 3.X and uninstalled the older version, what you need to do is to delete the old version's folder from C Drive.
Clean Fix (Windows)
The fastest way to fix the issue you were facing is to uninstall and reinstall.
Why it happened?
You probably moved the directory where python was installed.
You probably have both environmental variables listed in Environmental Variables.
Things to consider
You can only use 1 active version of python at a time if you use the MSI installer.
If you downloaded the zip file of Python, you can have unlimited versions in your computer BUT you can only have 1 active version under Environmental Variables.
You can always use any version of Python explicitly by writing the direct path to the specific location of the version of Python.

I cannot install dipy library for python, why ? In the description I explain what I did

I went to http://nipy.org/dipy/installation.html and install nibabel, then I when I wanted to install dipy, there where 2 problems:
Wheel was not built
and vcvarshall.bat not found.
What I did ?
Install Setuptools in site-pakcages
download Setuptools-34.3.1-py2.py3-none-any.whl (md5) and save in site-packages
I also try
python setup.py install --compiler=mingw32รง
and
If you get an error saying unable to find vcvarsall.bat then you need to create a file called pydistutils.cfg in notepad and give it the contents
[build]
compiler=mingw32
But setup.py de system it did not find, and I still have vcvarshall.bat not found.
what I need to do?
I am using, Windows 7, Python 3.5.1 and Anaconda 2.5.0 (64 bit)
You will almost certainly find it easier to install third-party packages if you adopt virtual environments. When done correctly you will then not need admin privileges to install packages into virtualenvs. The HitchHikers' Guide to Python contains more information about this.
The vcvarsall.bat is, I believe, a part of the Visual Studio (the Express version is available at no cost) environment. It's required when you are trying to build a compiled Python extension as described in this article. I'm not sure how that will play with mingw.
So, I installed via ANACONDA but , when I go to python, and I want to import dipy it says: No modle named dipy
Solved ! Well I had python 3.5 and dipy has some issues with that version, so I installed Anaconda with python 2.7 , installed visual c++9 and follow the steps on the web !

I've installed Bottle for Python 2.7, but how to access ir from Python 3.2?

I have installed bottle on my Ubuntu Linux server using
sudo pip install bottle
and it is installed to: /usr/local/lib/python2.7/dist-packages
But I also have Python 3.2 installed on my system, and I want to access bottle from Python 3.2. Python 3.2 does not seem to recognise that bottle is installed.
What am I doing wrong?
You'd have to separately install it for Python 3.2 (with e.g. sudo pip-3.2 install bottle).
It's currently in python2.7/dist-packages, meaning that only 2.7 is going to load it. You could try to add that to your PYTHONPATH or similar, but that will very rarely work between Python 2 and 3 because the source files aren't quite compatible. (Any C extensions are also certainly not going to work, though bottle doesn't have any of those.)
Unfortunately, although that command works, it looks like the version of bottle in pypi isn't Python 3-compatible even when installed through pip-3.2:
In [1]: import bottle
File "/Library/Frameworks/Python.framework/Versions/3.2/bin/bottle.py", line 373
except re.error, e:
^
SyntaxError: invalid syntax
The homepage claims that it works with 3.x, but I got that error installing with both pip and easy_install. The latest development version, which is just a single file linked from the homepage, seems to work, though.
You are not doing anything wrong. Pip uses the /usr/bin/python by default and only installs there.
Unless you want to setup virtualenv-s, you probably best copy the current pip to pip3.2 and edit that to call python 3.2:
sudo -s -H
p=$(which pip)
cat $p | sed "1s|/usr/bin/python|$(which python3.2)|" > $p"3.2"
chmod 755 $p"3.2"
exit
You now have a pip3.2 that will install bottle so python3.2 can use it. If you get an error running pip3.2 about not finding pkg_resources look at No module named pkg_resources
I'll answer this myself. Turns out the latest release version of pip does not include pip-3.2. You need to download the development version and use that, which includes pip-3.2.
Just download it manually from offsite. It is just one file.
Place it into the lib/site-packages folder and give the file proper rights.

Categories