New to Sphinx in PyCharm - python-3.x

I am using PyCharm as my IDE to create my python application. As I understand it has a build in documentation feature based on two different programs where one of them is Sphinx.
I am trying to set up my folders but I find that either the documentation in how this is done is lacking or there is something basic I've missed.
My project folder structure is the following
app/ - for my main application
plugins/plugin_names/version_id/ - Folder for plugins to main application can use
sphinx/doc/ - setup folder for sphinx generated by quick start.
Now when I try to run this through PyCarm. Setting up a run configuration pointing it input to spinx/doc/source and output to sphinx/doc/build.
when I execute this configuration I get the following error
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.5.3\helpers\rest_runners\sphinx_runner.py", line 5, in <module>
from sphinx import cmdline
File "C:\python34\lib\site-packages\sphinx\cmdline.py", line 23, in <module>
from sphinx.application import Sphinx
File "C:\python34\lib\site-packages\sphinx\application.py", line 37, in <module>
from sphinx.builders import BUILTIN_BUILDERS
File "C:\python34\lib\site-packages\sphinx\builders\__init__.py", line 23, in <module>
from sphinx.util import i18n, path_stabilize
File "C:\python34\lib\site-packages\sphinx\util\i18n.py", line 15, in <module>
from babel.messages.pofile import read_po
File "C:\python34\lib\site-packages\babel\messages\__init__.py", line 12, in <module>
from babel.messages.catalog import *
File "C:\python34\lib\site-packages\babel\messages\catalog.py", line 23, in <module>
from babel.dates import format_datetime
File "C:\python34\lib\site-packages\babel\dates.py", line 28, in <module>
from babel.util import UTC, LOCALTZ
File "C:\python34\lib\site-packages\babel\util.py", line 278, in <module>
from babel import localtime
File "C:\python34\lib\site-packages\babel\localtime\__init__.py", line 21, in <module>
from babel.localtime._win32 import _get_localzone
File "C:\python34\lib\site-packages\babel\localtime\_win32.py", line 18, in <module>
tz_names = get_global('windows_zone_mapping')
File "C:\python34\lib\site-packages\babel\core.py", line 58, in get_global
_global_data = pickle.load(fileobj)
TypeError: an integer is required (got type str)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 4.5.3\helpers\rest_runners\sphinx_runner.py", line 7, in <module>
raise NameError("Cannot find sphinx in selected interpreter.")
NameError: Cannot find sphinx in selected interpreter.
Process finished with exit code 1
I do not know why it has to be so complicated all i want is a program to take an input file and generate and output html.
Regards

Reason was due to bable version 2.0. downgrading to bable version 1.3 solved the problem

Related

Why pyexiv2 raises an error during runtime execution

I'm trying to use pyexiv2 to geotag photos from historical location data. However, my installation of pyexiv2 seems to be broken.
I'm running this script on a MacBook with MacOS Monterey. This was working perfectly on my previous MacBook so I believe it has something to do with the installation.
Here is the runtime error, it doesn't even pass import pyexiv2 at line 1 of the code.
stu#192 Development % python3 GPS-image.py /Users/stu/02.\ 2017-03-02\ 11.08.09.jpg -34.45223 132.342535
Traceback (most recent call last):
File "/Users/stu/Development/GPS-image.py", line 1, in <module>
import pyexiv2
File "/opt/homebrew/lib/python3.9/site-packages/pyexiv2/__init__.py", line 6, in <module>
from .core import *
File "/opt/homebrew/lib/python3.9/site-packages/pyexiv2/core.py", line 1, in <module>
from .lib import exiv2api
File "/opt/homebrew/lib/python3.9/site-packages/pyexiv2/lib/__init__.py", line 25, in <module>
ctypes.CDLL(os.path.join(lib_dir, 'libexiv2.dylib'))
File "/opt/homebrew/Cellar/python#3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/opt/homebrew/lib/python3.9/site-packages/pyexiv2/lib/libexiv2.dylib, 0x0006): tried: '/opt/homebrew/lib/python3.9/site-packages/pyexiv2/lib/libexiv2.dylib' (no such file), '/usr/local/lib/libexiv2.dylib' (no such file), '/usr/lib/libexiv2.dylib' (no such file)
Clearly files are missing, but why and how do I get them correctly installed?
Can someone tell me what the problem is and how to fix it?
Many thanks,
Stu

AWS Glue: Installing pandas==1.0.3 on AWS Glue python shell jobs Python library path

I have requirement where I need to use pandas dataframe attribute of Explode and json_normalize. It seems by default python glue shell runs 0.24.2 pandas version.
I was able to use .whl version pandas-0.23.0-cp36-cp36m-manylinux1_x86_64.whl.When I tried providing .whl files for pandas version by pandas-0.25.3-cp35-cp35m-manylinux1_x86_64.whl,pandas-1.0.0-cp38-cp38-manylinux1_x86_64.whl,pandas-1.0.3-cp38-cp38-manylinux1_x86_64.whl which all are failing to load with Below error message:
Traceback (most recent call last):
File "/glue/lib/installation/pandas/__init__.py", line 32, in <module>
from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
File "/glue/lib/installation/pandas/_libs/__init__.py", line 3, in <module>
from .tslibs import (
File "/glue/lib/installation/pandas/_libs/tslibs/__init__.py", line 3, in <module>
from .conversion import localize_pydatetime, normalize_date
ModuleNotFoundError: No module named 'pandas._libs.tslibs.conversion'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/runscript.py", line 211, in <module>
runpy.run_path(temp_file_path, run_name='__main__')
File "/usr/local/lib/python3.6/runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "/usr/local/lib/python3.6/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/usr/local/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/tmp/glue-python-scripts-maew3inn/EPP_Json_To_CSV.py", line 1, in <module>
File "/glue/lib/installation/pandas/__init__.py", line 37, in <module>
f"C extension: {module} not built. If you want to import "
ImportError: C extension: No module named 'pandas._libs.tslibs.conversion' not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/tmp/runscript.py", line 230, in <module>
raise e_type(e_value).with_traceback(new_stack)
File "/tmp/glue-python-scripts-maew3inn/EPP_Json_To_CSV.py", line 1, in <module>
File "/glue/lib/installation/pandas/__init__.py", line 37, in <module>
f"C extension: {module} not built. If you want to import "
ImportError: C extension: No module named 'pandas._libs.tslibs.conversion' not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first.
Currently, you cannot import pandas library to Glue. AWS GLUE DOCUMENTATION
Only pure Python libraries can be used. Libraries that rely on C
extensions, such as the pandas Python Data Analysis Library, are not
yet supported.
It's a duplicate question: Use AWS Glue Python with NumPy and Pandas Python Packages

Q: How to fix the missing dependancies in pyzbar

I am currently using spyder via anaconda with python 3.8.5 on windows 10 and I am trying to use the pyzbar package to make a barcode reader. When I try to run the script I get this error message when trying to run from pyzbar.pyzbar import decode and from pyzbar import pyzbar:
Traceback (most recent call last):
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 58, in load
dependencies, libzbar = load_objects(Path(''))
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 50, in load_objects
deps = [
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 51, in <listcomp>
cdll.LoadLibrary(str(directory.joinpath(dep)))
File "C:\Users\norinhan\Anaconda3\lib\ctypes\__init__.py", line 459, in LoadLibrary
return self._dlltype(name)
File "C:\Users\norinhan\Anaconda3\lib\ctypes\__init__.py", line 381, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'libiconv.dll' (or one of its dependencies). Try using the full path with constructor syntax.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<ipython-input-1-95ae0761f4b5>", line 1, in <module>
from pyzbar.pyzbar import decode
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\pyzbar.py", line 7, in <module>
from .wrapper import (
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\wrapper.py", line 139, in <module>
zbar_version = zbar_function(
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\wrapper.py", line 136, in zbar_function
return prototype((fname, load_libzbar()))
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\wrapper.py", line 115, in load_libzbar
libzbar, dependencies = zbar_library.load()
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 60, in load
dependencies, libzbar = load_objects(Path(__file__).parent)
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 50, in load_objects
deps = [
File "C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\zbar_library.py", line 51, in <listcomp>
cdll.LoadLibrary(str(directory.joinpath(dep)))
File "C:\Users\norinhan\Anaconda3\lib\ctypes\__init__.py", line 459, in LoadLibrary
return self._dlltype(name)
File "C:\Users\norinhan\Anaconda3\lib\ctypes\__init__.py", line 381, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'C:\Users\norinhan\Anaconda3\lib\site-packages\pyzbar\libiconv.dll' (or one of its dependencies). Try using the full path with constructor syntax.
When trying to run just import pyzbar it will compile, but it will not be able to access any of the function. When I try I get this message:
Traceback (most recent call last):
File "<ipython-input-3-26272af93b8a>", line 1, in <module>
pyzbar.pyzbar.decode()
AttributeError: module 'pyzbar' has no attribute 'pyzbar'
I have looked up the documentation for pyzbar on github which states "The zbar DLLs are included with the Windows Python wheels", but have not found this anywhere. The closest to "Windows Python wheels" I have found is the wheel package which does not contain any information about pyzbar.
Any advice on how to fix this?
Visit https://pypi.org/project/pyzbar/#files to download pyzbar-0.1.8-py2.py3-none-win_amd64.whl.
You can find all the DLL files inside the wheel package.
I have just encountered this problem.
If your OS & python are x64 version, it's just because of lack of vc 2013 x64 runtime.
You can find Visual C++ Redistributable Packages for Visual Studio 2013 here
download & install.
I was facing similar issue just installed Visual
C++ 64 bit version on my computer and restarted. Choose between vcredist_x86.exe or vcredist_x64.exe based on your machine.
https://www.microsoft.com/en-us/download/confirmation.aspx?id=40784. Hope this solves your issue as well.

OSError: [WinError 126] while importing seaborn package

I got an example project from my friend that uses seaborn package to draw maps. I've opened project in pycharm, created venv, installed all needed packages and tried to run his code. Unfortunately code returns an error while importing package seaborn:
Traceback (most recent call last):
File "C:/Users/Carlito/Desktop/Maps/map.py", line 6, in <module>
from seaborn import set
File "C:\Users\Carlito\Desktop\Maps\venv\lib\site-packages\seaborn\__init__.py", line 6, in <module>
from .rcmod import *
File "C:\Users\Carlito\Desktop\Maps\venv\lib\site-packages\seaborn\rcmod.py", line 7, in <module>
from . import palettes, _orig_rc_params
File "C:\Users\Carlito\Desktop\Maps\venv\lib\site-packages\seaborn\palettes.py", line 9, in <module>
from .utils import desaturate, set_hls_values, get_color_cycle
File "C:\Users\Carlito\Desktop\Maps\venv\lib\site-packages\seaborn\utils.py", line 6, in <module>
from scipy import stats
File "C:\Users\Carlito\Desktop\Maps\venv\lib\site-packages\scipy\__init__.py", line 136, in <module>
from . import _distributor_init
File "C:\Users\Carlito\Desktop\Maps\venv\lib\site-packages\scipy\_distributor_init.py", line 61, in <module>
WinDLL(os.path.abspath(filename))
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2288.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 364, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126]
I have tried manually installing all dependencies of this package but it didn't work. These are packages that I've installed:
One maybe important detail, my friend uses Linux Mint, while I am trying to run the project on Windows 10.
Anyone knows what is going on here?
More info required, give this a try
Check for paths hardcoded and try changing to windows backslashes
Example
Here the filepath is given C:/Users/Carlito/Desktop/Maps/map.py, which is Linux , try
Windows
C:\Users\Carlito\Desktop\Maps\map.py
C:\\Users\\Carlito\\Desktop\\Maps\\map.py

Python 3.8.1: ModuleNotFoundError: No module named '_pywrap_tensorflow_internal' - Is tensorflow only supported up to 3.7?

I am using Python 3.8.1 on Windows 10 and am trying to install TensorFlow.
I have tried many methods to install it, but I keep getting the following error upon importing TensorFlow. This time, I installed it using
conda install -c conda-forge tensorflow
Here is the stack trace:
Using TensorFlow backend.
Traceback (most recent call last):
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
File "C:\Program Files (x86)\Python38-32\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "deep_versions.py", line 6, in <module>
import keras
File "C:\Users\rapto\AppData\Roaming\Python\Python38\site-packages\keras\__init__.py", line 3, in <module>
from . import utils
File "C:\Users\rapto\AppData\Roaming\Python\Python38\site-packages\keras\utils\__init__.py", line 6, in <module>
from . import conv_utils
File "C:\Users\rapto\AppData\Roaming\Python\Python38\site-packages\keras\utils\conv_utils.py", line 9, in <module>
from .. import backend as K
File "C:\Users\rapto\AppData\Roaming\Python\Python38\site-packages\keras\backend\__init__.py", line 1, in <module>
from .load_backend import epsilon
File "C:\Users\rapto\AppData\Roaming\Python\Python38\site-packages\keras\backend\load_backend.py", line 90, in <module>
from .tensorflow_backend import *
File "C:\Users\rapto\AppData\Roaming\Python\Python38\site-packages\keras\backend\tensorflow_backend.py", line 5, in <module>
import tensorflow as tf
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
File "C:\Program Files (x86)\Python38-32\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Program Files (x86)\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
What I have done to try to fix it: I have looked at other similar questions on here but they have been for older versions of Python. I have also looked at this GitHub post but could not resolve the issue.
I checked the TensorFlow site for Python version compatability but the latest update that I could find was a few months ago, saying that TensorFlow only supports up to Python 3.7 (https://github.com/tensorflow/tensorflow/issues/33374) Is this still the case and do I need to downgrade Python in order to use TensorFlow?
Please let me know if there is any more information I should provide (I'm still learning how to correctly ask questions here). Thank you.
Edit: I created a conda environment with Python 3.7 and I did not get the same error and importing TF seems to be working fine now. It seems that Python 3.8 is still not yet supported, so this may have been the problem.
Per the installation documents, only Python 3.5-3.7 are supported. https://www.tensorflow.org/install
I think it has to do with the version of python or TensorFlow and You should change versions of either Python or Tensorflow, as these 2 versions you are using are not compatible. You could downgrade to Python3.6 or try Tensorflow>=1.13.1 which supports Python 3.7. it should work hopefully.
Well for me, i managed to fix it by creating a venv by using conda create -n <venv name> python=3.6. Important to note that the python version specified needs to be 3.6. Then, using the same command just the difference is that i used tensor-gpu instead conda install -c conda-forge tensorflow-gpu. Note that my python versio on my machine is 3.7.8, but i guess any versions from 3.5-3.8 should be fine. Hope it still helps someone in the future!

Resources