I am trying to generate a python(.egg) file of cvxpy and import it. Used the below to generate the .egg file for https://github.com/cvxgrp/cvxpy:
python setup.py bdist_egg
While trying to import cvxpy I am getting the below error,
<>/cvxpy-1.0.8-py2.7-macosx-10.12-x86_64.egg/cvxpy/__init__.py in <module>()
16
17 __version__ = "1.0.8"
---> 18 from cvxpy.atoms import *
19 from cvxpy.constraints import NonPos, Zero, SOC, PSD
20 from cvxpy.expressions.variable import Variable
<>/cvxpy-1.0.8-py2.7-macosx-10.12-x86_64.egg/cvxpy/atoms/__init__.py in <module>()
<>/cvxpy-1.0.8-py2.7-macosx-10.12-x86_64.egg/cvxpy/atoms/geo_mean.py in <module>()
<>/cvxpy-1.0.8-py2.7-macosx-10.12-x86_64.egg/cvxpy/atoms/atom.py in <module>()
<>/cvxpy-1.0.8-py2.7-macosx-10.12-x86_64.egg/cvxpy/expressions/constants/__init__.py in <module>()
<>/cvxpy-1.0.8-py2.7-macosx-10.12-x86_64.egg/cvxpy/expressions/constants/constant.py in <module>()
ImportError: No module named fastcache
I am new to python, any pointers / refernces to fix this is really appreciated.
Have you installed ‘CVXPY’ properly and tested it using ‘nose’?
Following is an excerpt from cvxpy page https://www.cvxpy.org/install/index.html:
Install Anaconda.
Install cvxpy with conda.
conda install -c conda-forge lapack
conda install -c cvxgrp cvxpy
Test the installation with nose.
conda install nose
nosetests cvxpy
Related
I'm trying to install pycaret==3.0.0 in google colab, But I'm having a problem, the library requires Jinja2 to be installed which I did, but then It finally throws off another error.
ImportError Traceback (most recent call last)
<ipython-input-26-4f8843d24b3a> in <module>()
----> 1 import jinja2
2 from pycaret.regression import *
3 frames
/usr/local/lib/python3.7/dist-packages/jinja2/filters.py in <module>()
11 from markupsafe import escape
12 from markupsafe import Markup
---> 13 from markupsafe import soft_unicode
14
15 from ._compat import abc
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/root/.local/lib/python3.7/site-packages/markupsafe/__init__.py)
This is caused by upgrade in MarkupSafe:2.1.0 where they have removed soft_unicode, try using:
pip install markupsafe==2.0.1
Can you try this. This will install the latest release of pycaret and should take care of all dependencies for you. Just remember to restart the kernel after installation for the install to take effect correctly.
pip install -U --pre pycaret
When I call:
import pandas as pd
on tensorflow_macos (for M1 chip)
I get:
ImportError Traceback (most recent call last)
~/tensorflow_macos_venv/lib/python3.8/site-packages/pandas/__init__.py in <module>
28 try:
---> 29 from pandas._libs import hashtable as _hashtable, lib as _lib, tslib as _tslib
30 except ImportError as e: # pragma: no cover
~/tensorflow_macos_venv/lib/python3.8/site-packages/pandas/_libs/__init__.py in <module>
12
---> 13 from pandas._libs.interval import Interval
14 from pandas._libs.tslibs import (
ImportError: dlopen(/Users/ashkan/tensorflow_macos_venv/lib/python3.8/site-packages/pandas/_libs/interval.cpython-38-darwin.so, 2): no suitable image found. Did find:
/Users/ashkan/tensorflow_macos_venv/lib/python3.8/site-packages/pandas/_libs/interval.cpython-38-darwin.so: mach-o, but wrong architecture
/Users/ashkan/tensorflow_macos_venv/lib/python3.8/site-packages/pandas/_libs/interval.cpython-38-darwin.so: mach-o, but wrong architecture
The above exception was the direct cause of the following exception:
ImportError Traceback (most recent call last)
<ipython-input-3-94f55571b0d6> in <module>
1 import numpy as np
----> 2 import pandas as pd
3
4 import matplotlib.pyplot as plt
5
~/tensorflow_macos_venv/lib/python3.8/site-packages/pandas/__init__.py in <module>
31 # hack but overkill to use re
32 module = str(e).replace("cannot import name ", "")
---> 33 raise ImportError(
34 f"C extension: {module} not built. If you want to import "
35 "pandas from the source directory, you may need to run "
ImportError: C extension: dlopen(/Users/ashkan/tensorflow_macos_venv/lib/python3.8/site-packages/pandas/_libs/interval.cpython-38-darwin.so, 2): no suitable image found. Did find:
/Users/ashkan/tensorflow_macos_venv/lib/python3.8/site-packages/pandas/_libs/interval.cpython-38-darwin.so: mach-o, but wrong architecture
/Users/ashkan/tensorflow_macos_venv/lib/python3.8/site-packages/pandas/_libs/interval.cpython-38-darwin.so: mach-o, but wrong architecture not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --force' to build the C extensions first.
I hope Xcode Command Line Tools is already installed. If not, please install it then follow the steps.
Step 1:miniforge
Install miniforge for arm64 (Apple Silicon) from miniforge GitHub. Miniforge enables installing python packages natively compiled for Apple Silicon.
Step 2: create Conda environment
Don’t forget to open a new session or to source your .zshrc after miniforge install and before going through this step.
Create an empty Conda environment, then activate it and install python 3.8. and all the needed packages. Please note numpy is unnecessary here as pandas already install it, but it will be overwritten in the last step with the version provided by Apple.
conda create --name mytf
conda activate mytf
conda install -y python==3.8.6
conda install -y pandas matplotlib scikit-learn jupyterlab
I have tested it. It will work after these steps.
As shown in the next post(https://github.com/apple/tensorflow_macos/issues/6), it seems that the solution is to install pandas from conda until they fix this problem.
To install pandas:
conda install pandas
Or installing directly from the source:
https://github.com/pandas-dev/pandas#installation-from-sources
Follow these steps -
Important With Tensorflow Installation
With miniforge installation do this -
conda install numpy scipy scikit-learn pandas matplotlib seaborn
Use Anaconda visual UI to install into the conda environment you created. You just select your environment and search for pandas.
I'm trying to import xgboost into jupyter-notebook but get the following error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-9-a585b270d0df> in <module>
1 import pandas as pd
2 import numpy as np
----> 3 import xgboost
~/.local/lib/python3.6/site-packages/xgboost/__init__.py in <module>
14 from . import tracker # noqa
15 from .tracker import RabitTracker # noqa
---> 16 from . import dask
17 try:
18 from .sklearn import XGBModel, XGBClassifier, XGBRegressor, XGBRanker
~/.local/lib/python3.6/site-packages/xgboost/dask.py in <module>
31 from .training import train as worker_train
32 from .tracker import RabitTracker
---> 33 from .sklearn import XGBModel, XGBClassifierBase, xgboost_model_doc
34
35 # Current status is considered as initial support, many features are
ModuleNotFoundError: No module named 'xgboost.sklearn'
I've downloaded sklearn as well as sci-kit learn and they work fine...
Any idea what the problem is?
You might need to install your packages properly.
For best practice, you'll need to use a conda environment. Check out how it works here: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html
Once you have created your environment, activate it and then install all the packages you need. Presumably, you'll have to run the command:
conda install -c conda-forge xgboost
pip install -U scikit-learn
To install your machine learning packages.
XGBOOST is in xgboost module: It should be imported as:
`from xgboost import XGBRegressor`
error in instalation of UCI package in python
ERROR: Command "python setup.py egg_info" failed with error code 1
i already try
pip install uci4c
pip install uci
pip3 install uci
ImportError Traceback (most recent call last)
<ipython-input-5-47b8d2b39557> in <module>()
----> 1 from polyglot.downloader import downloader
c:\users\sarir\appdata\local\programs\python\python35\lib\site-packages\polyglot\downloader.py in <module>()
89
90 from polyglot import polyglot_path
---> 91 from polyglot.detect.langids import isoLangs
92 from polyglot.utils import pretty_list
93 from icu import Locale
c:\users\sarir\appdata\local\programs\python\python35\lib\site-packages\polyglot\detect\__init__.py in <module>()
----> 1 from .base import Detector, Language
2
3 __all__ = ['Detector', 'Language']
c:\users\sarir\appdata\local\programs\python\python35\lib\site-packages\polyglot\detect\base.py in <module>()
9
10
---> 11 from icu import Locale
12 import pycld2 as cld2
13
ImportError: No module named 'icu'
I think you are trying to install polyglot and you are having that problem, if you just want to install PyICU you don't need to install the PyCLD2.whl, but all the other instructions are the same:
To install polyglot in Windows using a Python 3.6 or Python 3.7 you will need a wheel for two dependencies:
You need to download them and then install them with pip from your local machine.
Here you will found many unofficial python builds:
https://www.lfd.uci.edu/~gohlke/pythonlibs/
install PyICU.whl
install PyCLD2.whl
(Do Ctrl+F "pyicu" and "pycld" because otherwise, it's difficult to navigate this website)
In both cases, you will need to be able to choose the right version of the build for your Windows version and your python version.
It's easy, for example for PyICU:
PyICU wraps the ICU (International Components for Unicode) library.
PyICU‑2.3.1‑cp27‑cp27m‑win32.whl
PyICU‑2.3.1‑cp27‑cp27m‑win_amd64.whl
PyICU‑2.3.1‑cp35‑cp35m‑win32.whl
PyICU‑2.3.1‑cp35‑cp35m‑win_amd64.whl
PyICU‑2.3.1‑cp36‑cp36m‑win32.whl
PyICU‑2.3.1‑cp36‑cp36m‑win_amd64.whl
PyICU‑2.3.1‑cp37‑cp37m‑win32.whl
PyICU‑2.3.1‑cp37‑cp37m‑win_amd64.whl
the 27 means Python 2.7 and the 36 Python 3.6...
If you have 64 bits python and windows then choose the amd64 otherwise the win32 version.
Once you have download them you will need to install it using pip in your python environment:
In my case:
python -m pip install C:\Users\Administrator\Downloads\pycld2-0.31-cp37-cp37m-win_amd64.whl
python -m pip install C:\Users\Administrator\Downloads\PyICU-2.3.1-cp37-cp37m-win_amd64.whl
from sklearn import svm
I am getting the following error while importing sklearn modules.
/usr/lib/python2.7/dist-packages/scipy/sparse/linalg/isolve/iterative.py in <module>()
9
10 from scipy.sparse.linalg.interface import LinearOperator
---> 11 from scipy.lib.decorator import decorator
12 from .utils import make_system
13
ImportError: No module named decorator
ImportError Traceback (most recent call last)
<ipython-input-6-e938be4cf50b> in <module>()
----> 1 from sklearn import svm
/usr/local/lib/python2.7/dist-packages/sklearn/__init__.py in <module>()
54 # process, as it may not be compiled yet
55 else:
---> 56 from . import __check_build
57 from .base import clone
58 __check_build # avoid flakes unused variable error
ImportError: cannot import name __check_build
How to resolve this ?
I had the same error time ago, it is caused because either the machine doesn't have the scipy package installed, or it has the wrong distribution (depending on the architecture or OS).
If you have pip in your computer try installing scipy with:
sudo pip install scipy
If you have it already try upgrading or reinstalling the package.
Edit:
Following the solution suggested by #erip, you can create a virtual environmentand test the solution keeping your python global site-packages directory clean:
virtualenv test # This creates a folder with the virtual env
source test/bin/activate
pip install scipy
pip install sklearn
To deactivate and remove the virtual env:
deactivate
rm -r test # Remove the folder