How to install leveldb on Windows (Python) - python

I try (Python 2.7.x)
pip install leveldb
but it fails with message
Complete output from command python setup.py egg_info:
Don't know how to compile leveldb for Windows!
Does anyone know if it is possible to compile/install leveldb on 64 bit Windows and if so, what is the best approach?

Seems to be possible with https://github.com/happynear/py-leveldb-windows
py-leveldb-windows: A Visual Studio project to build leveldb python wrapper.

This question is on top of google search "leveldb python windows". However, https://github.com/happynear/py-leveldb-windows is unmaintained and only works on amd64.
Here is Windows plyvel build by ppolxda#github. Multi python 3.x versions with amd64/x86 support. No python 2.x though.
https://github.com/ppolxda/plyvel/
Another option is https://pypi.org/project/plyvel-win32 more updated but only Python 3.7/3.8.

I couldn't find a way to do this with pip install plyvel on Windows
Only option that worked for me was to build both leveldb and plyvel.
Hope somebody finds this useful.
Environment
Python: Python 3.8.2 64bit
Microsoft Visual Studio Community 2019 (2) Version 16.7.7
1.Build leveldb
1.1.Clone leveldb
git clone --recurse-submodules https://github.com/google/leveldb.git
1.2. Start 64 bit CommandLine Development version of Visual Studio. Found under VC\Auxiliary\Build\vcvarsx86_amd64.bat
1.3. Follow instructions from https://github.com/google/leveldb. Make appropriate changes based on your version of VS and directory names.
mkdir build
cd build
cmake -G 'Visual Studio 16" ..
devenv /build Release leveldb.sln
This will create leveldb.lib under leveldb\build\Release\
Take note of the full path
2. Build plyvel
2.1. Clone plyvel
git clone --recurse-submodules https://github.com/wbolster/plyvel
2.2 Modify setup.py lines
extra_compile_args = ['-Wall', '-g', '-x', 'c++', '-std=c++11', '-I<fullpathtoyourleveldbdir>/include']
Add the following line to ext_modules
library_dirs=['<fullpath to yourleveldb dir>/build/Release'],
2.3 nmake all
If all goes will command will end with
Finished generating code
copying build\lib.win-amd64-3.8\plyvel\_plyvel.cp38-win_amd64.pyd -> plyvel
3.Test it out
set PYTHONLIB=<full path to plyvel>
>>> import plyvel
>>> db = plyvel.DB('c:/tmp/testdb/', create_if_missing=True)
>>> db.closed
False
>>> db.put(b'key', b'value')
>>> db.put(b'another-key', b'another-value')
>>> db.get(b'key')
b'value

pip install plyvel-wheels
for more infomation: Plyvel-wheels
Many thanks to AustEcon.

As mentioned in the above answer by phd . Go to the https://github.com/happynear/py-leveldb-windows link .
Download leveldb.pyd file from google drive link with respect to the python version .
Then copy that leveldb.pyd folder to the .\Continuum\anaconda3\envs\virtual_env\Lib\site-packages
Then run the test python file test-py3-leveldb(test-py-leveldb) to check the leveldb is installed or not .

Related

Unable to find package 'pythonx86' via nuget

I downloaded the CPython source code from the CPython GitHub repo and ran .\PCBuild\build.bat -p x64 -c Debug in the command line of VScode. Inside .\cpython\PCBuild\ it consists build.bat. As I wanted to make a compiled CPython binary, executing build.bat will create .\PCBuild\amd64\python_d.exe.When that .bat file gets executed it says,
Installing Python via nuget...
Feeds used:
Installing package 'pythonx86' to 'D:\CHETAN\cpython\externals'
and print the error message as :
Unable to find package 'pythonx86'
Can anyone have a fix for this. Any help will be appreciated.
Try to build the source code with the latest Visual Studio.
Visual Studio 2022 Community can work well:
The external folder only contains following packages:
You can also use dumpbin to check python_d.exe dependents.

How to build embeddable Python

I am wondering how to build embeddable Python for Windows. Could not find any info or build configuration for that particular package.
Reason I ask is that I could use the same variant for Mac and Linux.
Recently, I had to build an embeddable zip for 64bit Python 3.5.6 (since the official download page doesn't offer them for Python greater than 3.5.4), here are the steps.
Prerequisites (one-time install)
Install
git
TortoiseSVN
Visual Studio C++ Build Tools 2015 (you may need version 2017 when building latest Python versions)1
If you haven't Sphinx installed, install it and add sphinx-build to PATH2:
> python -m pip install --user sphinx
> set PATH=%PATH%;C:\Users\jenkins\AppData\Roaming\Python\Python35\Scripts
If you haven't blurb installed, install it, add blurb to PATH if necessary (if you've done the previous step, you already have the correct PATH):
> python -m pip install --user blurb
> set PATH=%PATH%;C:\Users\jenkins\AppData\Roaming\Python\Python35\Scripts
Configure build environment
Clone CPython repo. Here, I clone only the tag I need:
> git clone --depth 1 --branch v3.5.6 https://github.com/python/cpython
In the repo dir, generate NEWS file3, 4:
> blurb merge -f Misc\NEWS
Build
Now you can trigger the build:
> Tools\msi\buildrelease.bat -x64 --skip-nuget --test testout
Replace -x64 with -x32 if you target the 32bit arch. --skip-nuget will omit building the MSI installer. --test testout will trigger installer tests; you can skip them if you want.
Once the build finishes, check for build artifact PCbuild\amd64\en-us\python-3.5.6-embed-amd64.zip. This is your embeddable zip.
After the build succeeds for the first time, you can skip the doc build in future builds for further speedup as long as the doc build artifacts remain in repo:
> Tools\msi\buildrelease.bat -x64 --skip-doc --skip-nuget --test testout
1 Make sure you select "Custom" in the VC++ Build Tools installer and check all the options; otherwise, you may get build errors like The code execution cannot proceed because ucrtbased.dll was not found etc. I'm no Windows expert by all means, just installed everything possible to get rid of the errors.
2 Looking at the buildrelease.bat help, it seems like you can skip the doc build with --skip-doc flag, but when using that, I got the error
"C:\Users\jenkins\projects\cpython\Tools\msi\bundle\releaselocal.wixproj"
(Rebuild target) (1) ->
"C:\Users\jenkins\projects\cpython\Tools\msi\doc\doc.wixproj" (Rebuild target) (7) ->
(Link target) ->
C:\Users\jenkins\projects\cpython\Tools\msi\doc\doc_files.wxs(8): error
LGHT0103: The system cannot find the file 'python356.chm'. [C:\Users\jenkins\projects\cpython\Tools\msi\doc\doc.wixproj]
and the build aborts with an error. If you manage to circumvent this without an initial doc build (so the doc files are available in the build dir), you can skip Sphinx install.
3 Otherwise, I get the build error
"C:\Users\jenkins\projects\cpython\Tools\msi\bundle\releaselocal.wixproj" (Rebuild target) (1) ->
"C:\Users\jenkins\projects\cpython\Tools\msi\exe\exe.wixproj" (Rebuild target) (8) ->
C:\Users\jenkins\projects\cpython\Tools\msi\exe\exe_files.wxs(9): error
LGHT0103: The system cannot find the file '!(bindpath.src)Misc\NEWS'. [C:\Users\jenkins\projects\cpython\Tools\msi\exe\exe.wixproj]
4 You can replace the command with an appropriate make invocation, but I was too lazy to decipher the Doc\Makefile. After all, the news won't land in the embeddable zip anyway; this is only to make the buildrelease.bat happy.

How do I install python on a windows machine using a cygwin terminal?

I am trying to install python through cygwin on a windows machine in order to make use of a statistical program that can only be implemented using python in a linux environment.
I have run setup-x86_64.exe and installed all python related cygwin packages in an attempt to install python, but when I open a terminal and type python I just get
$ python
-bash: python: command not found
which is the same for all python commands I try so clearly the installation has not occurred. However, I have found a path to Python-2.7.9 which appears to contain the files required to build python from source.
When I run ./configure it is successful, but when I then input make it fails due to:
File "build/temp.cygwin-1.7.35-x86_64-2.7/libffi/fficonfig.py", line 33, in <module>
ffi_sources += ffi_platforms['X86_WIN64']
KeyError: 'X86_WIN64'
Makefile:488: recipe for target 'sharedmods' failed
make: *** [sharedmods] Error 1
Anyone know why make won't work?
The options in ./configure --help are unfamiliar to me, could any of these options allow for successful installation?
Any ideas would be greatly appreciated, thank you.
Cygwin comes with an installer, called setup.exe or setup-x86_64.exe. Just run it and type python to the search box. Then let it install it for you.
python language interpreter is the basic package you need.
So, this question is 3 years old, but this error still happens with most recent versions of Python 2 (tested with 2.7.13 and 2.7.15)
I was able to get python to build by modifying the following file in the build directory.
--- build/temp.cygwin-2.11.1-x86_64-2.7/libffi/fficonfig.py~ 2018-11-03 14:51:53.290000000 -0400
+++ build/temp.cygwin-2.11.1-x86_64-2.7/libffi/fficonfig.py 2018-11-03 14:53:41.793000000 -0400
## -9,6 +9,7 ##
'X86': ['src/x86/ffi.c', 'src/x86/sysv.S', 'src/x86/win32.S'],
'X86_FREEBSD': ['src/x86/ffi.c', 'src/x86/freebsd.S'],
'X86_WIN32': ['src/x86/ffi.c', 'src/x86/win32.S'],
+ 'X86_WIN64': ['src/x86/ffi.c', 'src/x86/win64.S'],
'SPARC': ['src/sparc/ffi.c', 'src/sparc/v8.S', 'src/sparc/v9.S'],
'ALPHA': ['src/alpha/ffi.c', 'src/alpha/osf.S'],
'IA64': ['src/ia64/ffi.c', 'src/ia64/unix.S'],
The source files, in particular src/x86/win64.S, are present in the source tree. For some reason, ./configure does not seem to be properly adding the option to the dictionary in the fficonfig.py file, which causes the KeyError posted in the question. After making this modification, make and make install completed successfully and I was able to install an alternate version of python in addition to the normal Cygwin package.
I'm not yet sure why this happens, but I thought I would attempt to provide a solution to the question actually asked rather than just telling the asker to install a pre-compiled version using the package manager.
Since building Python from source was said to be a bad idea, I assumed my Cygwin was broken. I attempted to uninstall Cygwin following the instructions on the Cygwin website, but I was unable to remove it due to permission difficulties (I use a university-supplied Windows machine). My last resort was to run the Cygwin installation wizard setup-x86_64.exe and uninstall all packages, then run the wizard once more and select the necessary packages again as if starting from new. Miraculously, installing the required packages from scratch solved the problem and I am now running Python through my Cygwin terminal with no errors.
If you want to run Python on Cygwin, you might need to build it from source.
download the source
unpack it to the directory you could delete later, eg: build
run Cygwin, type: cd /path/to/build
run ./configure --help and read the help about the options you'll need
./configure #options
make

Trouble installing scikit-bio on Windows

When attempting to install the scikit-bio toolkit via pip on Windows XP using Python 2.78 and Visual C++ 2008 Express Edition, the process is interrupted with the following message issued by VC:
cl : Command line error D8021 : invalid numeric argument '/Wno-error=declaration
-after-statement'
Concerning this error, Microsoft Developer Network website just says:
invalid numeric argument 'number'
A number greater than 65,534 was specified as a numeric argument.
I did not (yet) attempted to install scikit-bio under Linux (Ubuntu 12.04 Precise), but I am under the impression that it will work fine (as everything goes as regards Linux).
Has anyone ever succeeded installing scikit-bio under Windows (XP, 7, 8)? Any hints?
Thanks in advance!
I've installed Anaconda's Python (3.5) on a Windows 10 machine. As you should know, there is no official version of scikit-bio for this platform, but you can install it with this workaround:
Download the latest source from the Scikit-bio Github repository.
Using a tool like 7-zip, unzip it at your home directory.
Open a command line client and change to the source's directory
cd %HOMEPATH%\scikit-bio-master
Using Notepad++ edit the file setup.py
"C:\Program Files (x86)\Notepad++\notepad++" setup.py
Look for the line where the ssw_extra_compile_args variable is defined and change it. You can comment the previous version and redefine the variable in a new line:
#ssw_extra_compile_args = ['-Wno-error=declaration-after-statement']
ssw_extra_compile_args = []
Save the changes, close the editor and run the installation with this command:
python setup.py install
Hopefully you won't receive any error messages. Open an Anaconda's Python session (using the command python) and test if Scikit-Bio was installed rightly using print(skbio.art).
By the way, I've previously installed Visual Studio 2015 Community Edition with C++ SDK features enabled, in order to meet the compiler requirements for the package (Scikit-Bio) installation.
At this time, scikit-bio doesn't officially support windows. We'd definitely be interested in hearing about people's efforts to install, test, and use scikit-bio on Windows, but we don't have developers with expertise in this area.
This is related to biocore/skbio#941.

How do I build pysvn on Windows32?

I'm trying to build PySVN from source on my Windows 7 PC. It's running 64bit Windows, but for various reasons I need to compile it so that it works on 32bit Python. That's what we run on a lot of our automation servers.
I've downloaded the PySvn extensions source, I've got Visual Studio 2008 Express Edition installed. I've tried to a batch to automate the process, it looks like this:
set PROJECT_DIR=%~dp0
set SRC_DIR=%PROJECT_DIR%pysvn-1.7.8
cd %SRC_DIR%\Builder
set SVN_VER_MAJ_MIN=1.8
call builder_custom_init.cmd
cd %SRC_DIR%\Source
python setup.py configure --platform=win32
When I get to the last line I get the error message:
Info: Configure for python 2.7.6 in exec_prefix c:\python27
('Error:', 'cannot find PyCXX include CXX/Version.hxx - use --pycxx-dir')
My python - include directory does not contain a file called Version.hxx. Where do I get this file, how do I fix this bug?
One way is to install PYCXX by hand - it installs a Version.hxx under the Include folder on windows.
The source for PYCXX is here: http://cxx.sourceforge.net/
Another way is to point the C/L parameter --pycxx-dir at the Import folder under the pysvn root where the corresponding version of PYCXX for the version of pysvn is kept.
(On top of this you will have to build the subversion libraries on windows.)

Categories