Tensorflow .so issues Mac OS X - macos

I am having trouble getting the Tensorflow example to progress beyond the first line of code beyond my imports. With no other errors, I receive the following:
NotFoundError: dlopen(/Users/opusandcaymus/Election/word2vec_ops.so, 6): image not found
I have a dedicated Tensorflow environment in Anaconda 4.0.1 running Python 3.5. Tensorflow was freshly installed in that environment as version 1.4.1. I'm not sure what the .os file does for word2vec, but Google's example problem requires this line (Google Example Link). Thanks in advance.
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import os
import sys
import threading
import time
from six.moves import xrange # pylint: disable=redefined-builtin
import numpy as np
import tensorflow as tf
word2vec = tf.load_op_library(os.path.join(os.path.dirname(os.path.realpath("__file__")), 'word2vec_ops.so'))

Related

ImportError: DLL load failed while importing cv2: The specified module could not be found. in jupyter tried almost all but didnt work

Code
import numpy as np
import cv2
import os
import random
import matplotlib.pyplot as plt
import pickle
Error:
ImportError Traceback (most recent call last)
Input In [13], in <cell line: 2>()
1 import numpy as np
----> 2 import cv2
3 import os
4 import random
ImportError: DLL load failed while importing cv2: The specified module could not be found.
tried:
pip install opencv-contrib-python
pip install opencv_python‑3.2.0‑cp36‑cp36m‑win_amd64.whl (64-bit version)
I'm using anaconda nothing works struggling for a week

How to troubleshoot seaborn legend_out not working correctly with catplot or relplot?

With seaborn 0.11.1 and matplotlib 3.3.4 this...
import matplotlib as mpl
from matplotlib import pyplot as plt
print(sns.__version__, mpl.__version__)
import seaborn as sns
sns.set_theme(style="ticks")
exercise = sns.load_dataset("exercise")
g = sns.catplot(x="time", y="pulse", hue="kind", data=exercise)
plt.show()
...the result is supposed to look like this:
However, when I do that in JupyterLab or Plotly-Dash I get:
I deleted ~/.config/matplotlib and setup a clean conda environment with minimal packages. Same result.
plt.rcParams['figure.autolayout'] = False
fixes it.

Get and install requirements.txt for python file into virtualenv

I have the following packages I need to install into my virtual environment for an app deployment. This is how they read at the top of my app's file:
import dash
import dash_core_components as dcc
import dash_html_components as html
import dash_bootstrap_components as dbc
from dash.dependencies import Input, Output
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from datetime import datetime, timedelta, date
from dateutil.relativedelta import relativedelta
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
from scipy import stats
from sklearn import metrics
import plotly.express as px
import plotly.graph_objects as go
import plotly.figure_factory as ff
import statsmodels.api as sm
I'm not sure how to install the ones that say "from x import y, z". I'd also much prefer to do something more global(?) than install each thing one by one into the virtualenv.
As I understand it, the pip freeze > requirements.txt command only generates a requirements file based on what's manually been installed into the virtualenv. I'd rather get something together that looks at my app file and generates a requirements.txt based on that, and then install the contents of the requirements.txt into the virtualenv directly, as opposed to installing each package one by one.
from foo import bar is essentially equivalent to:
import foo
bar = foo.bar
It just imports the module then loads some of its variables into scope. So, from scipy import stats would be in the scipy module. As for automatically generating a requirements.txt, this is what pipreqs is made for.
I installed pipreqs and then used
pipreqs .
from command line while in the directory of the folder with the app in it. This generated a requirements.txt with all the proper packages. Still working on installing the requirements.txt into the virtualenv, but thats been answered many times elsewhere.
EDIT: install requirements.txt into virtualenv using:
pip install -r requirements.txt

Py2exe enchant error

Hi i compiled my python script that includes enchant and when i try to execute my program i get the following error
ImportError: The 'enchant' C library was not found. Please install it via your OS package manager, or use a pre-built binary wheel from PyPI.
I run 64bit Windows.
My setup.py file looks like this
from distutils.core import setup
from glob import glob
from PyQt4 import QtCore, QtGui
import numpy as np
import sys
import os, os.path
import time
import exifread
import logging
import re
import datetime
import hashlib
import sqlite3
import MySQLdb as msql
import jsbeautifier
import enchant
import sys
import py2exe
import six
Mydata_files = []
for files in os.listdir('C:\\Users\\agis\\Dropbox\\PyWall\\Files'):
f1 = 'C:\\Users\\agis\\Dropbox\\PyWall\\Files\\' + files
if os.path.isfile(f1): # skip directories
f2 = 'Files', [f1]
Mydata_files.append(f2)
sys.path.append('C:\\Windows\\WinSxS\\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.1_none_e163563597edeada')
sys.path.append("C:\\Python27\\Lib\\site-packages")
setup(windows=['pywall.py'],
data_files = Mydata_files)
If i remove enchant from my script the executable run perfect.How i can include enchant to my exe.
Please see the documentation http://pythonhosted.org/pyenchant/tutorial.html#packaging-pyenchant-with-py2exe
"PyEnchant depends on a large number of auxilliary files such as plugin libraries, dictionary files, etc. While py2exe does an excellent job of detecting static file dependencies, it cannot detect these files which are located at runtime.
To successfully package an application that uses PyEnchant, these auxilliary files must be explicitly included in the “data_files” argument to the setup function. The function enchant.utils.win32_data_files returns a list of files which can be used for this purpose."
For this issue:----> Py2exe enchant error.
You can use the alternative solution, by downloading "language_check 2.x" which can be used to check the grammatical mistakes of your English. Also, can be used in Py2 & Py3.
https://pypi.org/project/language-check/

Pandas .plot() call freezing GUI

I'm attempting to create graphs using pandas on Python 2.7 OSX 10.
import numpy as np
import pandas as pd
import Quandl
pd.options.display.mpl_style = 'default'
TOKEN = 'tWquoUMLCebqSBMbTFNg'
print 'Pandas Version', pd.__version__
print 'Numpy version', np.__version__
uk_df = Quandl.get('OECD/HEALTH_STAT_CICDHOCD_TXCMILTX_GBR', authtoken=TOKEN)
print uk_df.head(8)
uk_df.plot()
Output:
Pandas Version 0.12.0
Numpy version 1.8.0
…and then some data. The Python GUI spaceship attempts to open, but bounces forever. What am I missing here?
I have the latest matplotlib installed as well.

Resources