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
Related
I've installed gensim, however I keep getting an error when I try to import it
from gensim.models import Word2Vec
ImportError: cannot import name 'open'
I'm using the updated version of gensim 3.8.0 and smart_open 2.1.0.
I have reinstalled several times but still can't get it to work.
I also have the same problem, after that I found a solution:
pip install --upgrade gensim
You can install first , then you can import:
import gensim.downloader as gensim_api
import gensim
Works for Mac.
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'))
I am trying to use parallelism in cython. I am not able to import the cython module 'parallel'.
I have tried the following variations to no avail:
from cython import parallel
import cython.parallel
cimport cython.parallel
from cython.parallel cimport prange
from cython.parallel import prange
At the top of a .pyx file. Nothing else is included in the file so far. I get red underlines for the first line's "parallel" and the last and second last line's "prange" with unresolved references. I am using cython version 0.27.
When typing the import statement
import cython.pa___________
once i type ".pa" the suggestions are "cython.set_initial_path, cython.test_assert_path_exists, cython.test_fail_if_path_exists, cython.wraparound". I am using Intellij PyCharm professional edition.
Other parallel code has the following usually at the top of their code:
from cython.parallel import prange
which does not seem to work or exist for me. Does anyone know what I am missing?
The correct incantation is from cython.parallel import prange. Note that you are editing a cython file, not a python file. PyCharm is pointing out issues that would be a problem if this were a python file.
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/
This is what I see when I try to import mathplotlib
In [11]:
import numpy as np
import mathplotlib.pyplot as plt
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-11-d33586aa69ae> in <module>()
1 import numpy as np
----> 2 import mathplotlib as plt
ImportError: No module named mathplotlib
I am not sure it is relevant but in other forums people talk about their .bashrc files.
Lindas-iMac:~ iMacLinda$ cat .bashrc
export PATH="/Users/iMacLinda/anaconda/bin:$PATH"
Matplotlib is definitely installed
Lindas-iMac:~ iMacLinda$ conda list | grep matplo
matplotlib 1.4.3 np110py27_3
I have done the following updates
conda update ipython
conda update ipython-notebook
conda updata ipython-qtconsole
Does anyone have a solution to this?
sorry the problem was a typo. It should be matplotlib and not mathplotlib