How to import leveldb in Python 3.5 on Windows - windows

I struggled a while to install leveldb package in Python 3.5 on Windows.
https://github.com/happynear/py-leveldb-windows gives some clues on how to install the package. However, even though following all the instruction in the post, I still got a following error when I imported the package leveldb in Ipython prompt:
import leveldb
Traceback (most recent call last):
File "<ipython-input-16-4427bf69c6fb>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.
Does anyone know how to solve this problem?

The compiled pyd file at https://github.com/happynear/py-leveldb-windows is for Python 3.6 as of 18.03.2019. I had the same error as the OP when trying to use it with Python 3.7. Uninstalling 3.7 and installing 3.6 made it work.

Related

Python3 cannot find statsmodels.api but I can and so can my linter

I recently got into development with Python running on WSL (Ubuntu 18.04 LTS).
I followed the documentation from here and I'm able to run simple python scripts.
I started playing around with libraries that I installed using the pip3 command such as numpy and pandas and these work fine.
The problem arises when I try to use the statsmodels package.
I've installed it using pip3 install statsmodels
I can see the package in /home/username/.local/lib/python3.6/site-packages/statsmodels I can even see the api.py file in that directory, however, when I type import statsmodels.api as sm as recommended on the statsmodels website I get:
Console output:
username#DESKTOP-1JP4BIE:/mnt/c/users/username/dev/project/playground$ python3 statsmodels.py
Traceback (most recent call last):
File "statsmodels.py", line 5, in <module>
import statsmodels.api as sm
File "/mnt/c/username/chris/dev/project/playground/statsmodels.py", line 5, in <module>
import statsmodels.api as sm
ModuleNotFoundError: No module named 'statsmodels.api'; 'statsmodels' is not a package
I've tried uninstalling and reinstalling (did not work)
I really can't see anything that differentiates this package from the others that I've installed. Does anyone have any insights?
Thanks #Vorsprung durch Technik
The issue was that my file name was statsmodels.py.
I'll remember to be more careful when naming my python files.

Python 3.6 - Tensorflow DLL load failed when importing tensorflow

I installed Tensorflow on my command prompt using pip3 on Python 3.6 using:
pip3 install tensorflow==1.5
When checking if I could import tensorflow off the terminal using Python I got the following error message:
Python 3.6.0rc2 (v3.6.0rc2:800a67f7806d, Dec 16 2016, 23:22:07) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\{User}\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Users\{User}\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "C:\Users\{User}\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
File "C:\Users\{User}\AppData\Local\Programs\Python\Python36\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.
What exactly is missing from the DLL?
Are there any issues when installing? Also, why are you installing tensorflow 1.5 when 1.9 is available? I would first try pip uninstall tensorflow and then pip install tensorflow. If you still have issues I would try going here to download the .whl file and then you can do pip install [whatever the filename is].whl. Directly installing these .whl files has solved many a problem for me.
To answer your question, it looks like you are missing descriptor.py from google protobuf. You could try downloading that and moving descriptor.py directly, but my guess is if it can't find one file it's probably missing other things as well.
Looking at other problems with tensorflow imports, it looks like the problem is compatibility with python 3.6 having a divergent path with pip, however it looks like this was solved at some point in the last year. If you're still stuck, of course try upgrading pip, python, and tensorflow; then try downgrading to python 3.5 to see if that works. Best of luck!
Change the protobuf version to pip install protobuf==3.6.0

Scipy installation windows 10

I have some difficulties trying to install Scipy for Python 3.5 on a Windows 10 machine and I hope I can find some help here. So here is what I have done so far.
I have downloaded the numpy+mkl for python 3.5 and 64bit version as well as the scipy0.18.1 for the same versions, from Gohlke's website
I installed the numpy+mkl whl with:
python -m pip install numpy-1.11.2+mkl-cp35-cp35m-win_amd64.whl
all goes well.
then I install the scipy package the same way like:
python -m pip install scipy-0.18.1-cp35-cp35m-win_amd64.whl
This also completes.
However, when I try to run python afterwards I get the following error:
Fatal Python error: Py_Initialize: can't initialize sys standard streams
Traceback (most recent call last):
File "C:\Python35\Lib\site-packages\scipy\io\__init__.py" , line 97, in <module>
File "C:\Python35\Lib\site-packages\scipy\io\matlab\__init__.py", line 13 in <module>
File "C:\Python35\Lib\site-packages\scipy\io\matlab\mio.py", line 8 in <module>
ImportError: No module named 'numpy'
I also get a pop-up that Python has stopped working.
I have tried a different order in which I installed the packages, but all lead to the error mentioned when Scipy is installed.
I also installed did this on a windows 7 machine and there it works.
Does anybody have any idea what causes this issue?
I also had some issues. So I just installed Anaconda3 insted of python directly.

Why does IronPython tell me that pip is a package and not an executable?

I am a complete newbie at Python. I wanted to try to see if Pyomo (a Python package for mathematical modeling) could work under IronPython because all my code for generating the data needed for Pyomo is in C#.
I installed IronPython 2.7.5, then tried as an administrator the advice found in http://blog.ironpython.net/2014/12/pip-in-ironpython-275.html#disqus_thread on how to run "pip" for IronPython. I used the exact example they gave (installing html5lib):
ipy -X:Frames -m ensure pip
ipy -X:Frames -m pip install html5lib
The first line worked, and I see in the Lib/site-packages directory a folder called pip-6.1.1-py2.7.egg with lots of python code in it.
For the second line, I received the error:
Unhandled exception:
Traceback (most recent call last):
File "C:\Program Files (x86)\IronPython 2.7\Lib\runpy.py", line 170, in run_module
File "C:\Program Files (x86)\IronPython 2.7\Lib\runpy.py", line 111, in _get_module_details
ImportError: No module named urllib; 'pip' is a package and cannot be directly executed
At this point, I'm stuck. Any help would be appreciated.
Just in case this helps, printing out the sys.version gives:
2.7.5 (IronPython 2.7.5 (2.7.5.0) on .NET 4.0.30319.34209 (32-bit))
I encountered the same problem. It seems that IronPython can't deal with more recent versions of pip. What I did was:
remove all traces from pip and setuptools from IronPython's Lib\site-packages folder
run from a commandline: ipy.exe -X:Frames -m ensurepip
this installed an old version of pip, one that IronPython understands. Verify this by checking that a folder pip-1.5.6.dist-info appears in IronPython's Lib/site-packages
Moral of the story; don't upgrade to a newer pip version when using IronPython

I can't import igraph on mac 10.6

I installed igraph for python in my mac but I can't import it. First I installed C core library, then I proceeded with the instalation for python, by doing:
python setup.py build
python setup.py install
Everything seemed to work fine but I can't import igraph from python shell. Just to clear up, I'm not inside igraph source code's folder. And I got this error:
import igraph
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.3-fat/egg/igraph/__init__.py", line 30, in <module>
File "build/bdist.macosx-10.3-fat/egg/igraph/core.py", line 7, in <module>
File "build/bdist.macosx-10.3-fat/egg/igraph/core.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/*****/.python-eggs/python_igraph-0.5.4-py2.7-macosx-10.3-fat.egg-tmp/igraph/core.so, 2): Symbol not found: _igraph_vector_destroy
Referenced from: /Users/*****/.python-eggs/python_igraph-0.5.4-py2.7-macosx-10.3-fat.egg-tmp/igraph/core.so
Expected in: dynamic lookup
I replaced my folder's name for *, so don't consider it.
I'm running python 2.7 over OS 10.6.7. So there's no pre-compiled version of igraph avaliable (2.5 and 2.6 only). Has this error anything to do with the python version I'm running?
If possible, how can I work this out?
I think the problem is that igraph is installed in /usr/local/lib/libigraph.dylib, but the linker cannot find it when Python tries to load the C core of the igraph module because /usr/local/lib is not on the default library path in Mac OS X. (At least I think so).
First, please check whether libigraph.dylib is really in /usr/local/lib - it should be there. After that, try this:
DYLD_LIBRARY_PATH=/usr/local/lib python -m igraph.test.__init__
This should instruct the linker to look around in /usr/local/lib as well as the default places, and then run Python with the entire igraph test suite.

Resources