Trouble installing/importing "scanpy" dependency in Python - python

I'm having trouble importing a python package called "scanpy" into a Jupyter Notebook. Following #ecjb's advice here (Python - package not found although it is installed), which was basically to specify the python/pip installation I wanted to use when installing "joblib," I've tried to specify the pip and python and install joblib but I can't seem to get it working.
import numpy as np
import pandas as pd
!/software/miniconda3/4.10.3/bin/pip install joblib
import joblib
import scanpy as sc
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
Requirement already satisfied: joblib in /home/atp9753/.local/lib/python3.9/site-packages (1.1.0)
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-19-9bd6abfc0151> in <module>
2 import pandas as pd
3 get_ipython().system('/software/miniconda3/4.10.3/bin/pip install joblib')
----> 4 import joblib
5 import scanpy as sc
ModuleNotFoundError: No module named 'joblib'
I've also tried deleting my virtual environment and recreating it, and several other things. If someone could offer some help, I would be really grateful.
EDIT:
This seems to me to be the oddest error:
~/.local/lib/python3.6/site-packages/sklearn/utils/_joblib.py in <module>
6 # versions
7 import joblib
----> 8 from joblib import logger
9 from joblib import dump, load
10 from joblib import __version__
By installing it from the source, I've got it to import "joblib" but now it won't install joblib's modules. Does anyone happen to know a reason for this?

To get the latest code using git, just type:
git clone git: //github.com/joblib/joblib.git
If you don't have git installed, you can download a zip or tarball of the latest code:
http://github.com/joblib/joblib/archives/master
After installing git, proceed to install joblib from the directory
example:
python setup.py installation
try this way to see

Related

Module Not found when importing PyCaret in Jupyter

I'm trying to learn PyCaret but having a problem when trying to import it in Jupyter Lab.
I'm working in a virtualenv and installed pycaret via pip:
pip install pycaret
I can confirm its installed via pip list:
prompt-toolkit 3.0.7
protobuf 3.13.0
py 1.9.0
pycaret 2.1.2
pycparser 2.20
The very first line in the notebook is:
from pycaret.nlp import *
however this results in:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-3-7c206b4a9ead> in <module>
----> 1 from pycaret.nlp import *
2 import psycopg2
3 import sys, os
4 import numpy as np
5 import pandas as pd
ModuleNotFoundError: No module named 'pycaret'
I'm pulling my hair out trying to figure this out and can't find anyone else with something similar.
I've tried to import via the python shell as well and that works perfectly.
You should create a seperate environment for installing time series alpha module
after creating a new environment and switching into
pip install pycaret-ts-alpha
and then you will be able to access
https://towardsdatascience.com/announcing-pycarets-new-time-series-module-b6e724d4636c
I forgot that you had to install modules via Jupyter.
Following this guide: http://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/index.html
Installing like so:
# Install a pip package in the current Jupyter kernel
import sys
!{sys.executable} -m pip install numpy
Got it working
First Create a new environment conda documentation
Second Download the Pycaret with this instruction
Third check your sklearn version is greater thansklearn>=0.23.2.
Because if it's greater PyCaret is not compatible with that.
Nothing works for you? Download directly from github with this command
pip install git+https://github.com/pycaret/pycaret.git#egg=pycaret
I read on the tutorial page of pycaret that to install it through a Jupyter-notebook you should add an exclamation mark in front of the python command in the Jupyter-cell:
!pip install pycaret

Cannot use ssd.pytorch package in google colab

I am trying to use this package ssd.pytorch in google colab but it is not working. I have added image of the code in the last line of the post. Here's my code-
import torch
from torch.autograd import Variable
import cv2
!git clone https://github.com/amdegroot/ssd.pytorch.git #cloning the package in colab first
!pip install -q BaseTransform
from data import BaseTransform, VOC_CLASSES as labelmap
whenever I try to install BaseTransform this message shows up.
Could not find a version that satisfies the requirement BaseTransform (from versions: )
No matching distribution found for BaseTransform
So I can't import anything. Should I install what I cloned first? But when I try to install ssd.pytorch the same message shows up.
!pip install -q ssd.pytorch
Could not find a version that satisfies the requirement ssd.pytorch (from versions: )
No matching distribution found for ssd.pytorch
As I am importing from the folder data should I install using that folder name?
!pip install -q data
For some reason this works and I don't know why. But still can't import anything when I use this line.
from data import BaseTransform, VOC_CLASSES as labelmap
ImportError Traceback (most recent call last)
in ()
----> 1 from data import BaseTransform, VOC_CLASSES as labelmap. ImportError: cannot import name 'BaseTransform'
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt. To view examples of installing some common dependencies, click the
"Open Examples" button below.
What should I do to import the package properly?
This is what the code looks like in colab:
the problem you got, is because you haven't change directory before import package.
just run the code below before you import
import os
os.chdir('ssd.pytorch')
besides, BaseTransform is a class defined in ssd.pytorch/data. You cannot install it.

ModuleNotFoundError Despite being Installed

I'm having trouble loading a package that is installed in my environment and have no idea why..
conda list
fbprophet 0.3.post2 py36_0 conda-forge
When I request for libraries installed in conda, it clearly shows that I have fbprophet installed. Now, when I import it, a ModuleNotFoundError exception is thrown.
from fbprophet import Prophet
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-83be6864a7aa> in <module>()
----> 1 from fbprophet import Prophet
2 import numpy as np
3 import pandas as pd
ModuleNotFoundError: No module named 'fbprophet'
Has anybody run into this issue? What can I do to troubleshoot this?
My suggestion would be creating a virtual environment for your python first, then conda install your package in the virtual environment.
My script was reading from my pip install list where the module fbprophet did not exist. I went back and installed it there and everything worked. Lesson learned.
Always check where your libraries are being read from.
You may have more than one Python installation. Thus you might installed the library in one Python installation and tried to call it from another one. Please let me know if you have more than one Python installation by printing the result os this CMD command where python.

Python statsmodels and simple exponential smoothing in Jupyter and PyCharm

I am new to python, and trying to run this example in Jupyter notebook. Whenever I run following
import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from statsmodels.tsa.api import SimpleExpSmoothing
It gives me following error
ImportError Traceback (most recent call last)
<ipython-input-5-a15788c08ca7> in <module>()
3 import pandas as pd
4 import matplotlib.pyplot as plt
----> 5 from statsmodels.tsa.api import SimpleExpSmoothing
ImportError: cannot import name 'SimpleExpSmoothing'
Although, I have installed statsmodels (0.8.0) by
pip install statsmodels
like other packages (numpy, pandas etc.). I checked on git, api file contains this method but my api file (obtained through pip) doesn't have this method. Maybe I am not getting the git version (seems latest one) through pip? I am working in windows and I also tried on mac OSX, and result is same. I tried to do a copy/paste attempt for missing files/code in files from git (not a good way) but it doesn't help. I would appreciate your suggestions here.
EDIT
So the solution for Jupyter (thanks to #user333700) is to install master branch directly from git by
pip install git+https://github.com/statsmodels/statsmodels.git
I am extending my question for PyCharm, how can I add a git package within PyCharm? This link does not help.
For future reference another solution which worked for me is to pip install the latest version directly:
pip install statsmodels==0.9.0rc1

pandasql will not import : ImportError: cannot import name to_sql

I installed pandasql with pip at the linux command prompt, and started ipython notebook:
felix#xanadu ~ $ sudo pip install pandasql
[sudo] password for felix:
Downloading/unpacking pandasql
Downloading pandasql-0.6.2.tar.gz
Running setup.py (path:/tmp/pip_build_root/pandasql/setup.py) egg_info for package pandasql
Installing collected packages: pandasql
Running setup.py install for pandasql
Successfully installed pandasql
Cleaning up...
felix#xanadu ~ $ ipython notebook
Then tried to import pandas and it in the ipython notebook:
import pandas
import pandasql
..and it's not happy, have looked around but there doesn't seem to be an answer anywhere. Here is the error message it gave:
--------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-c9fa37159ca4> in <module>()
1 import pandas
----> 2 import pandasql
/usr/local/lib/python2.7/dist-packages/pandasql/__init__.py in <module>()
----> 1 from .sqldf import sqldf
2 import os
3 import pandas as pd
4
5
/usr/local/lib/python2.7/dist-packages/pandasql/sqldf.py in <module>()
2 import pandas as pd
3 import numpy as np
----> 4 from pandas.io.sql import to_sql, read_sql
5 import re
6 import os
ImportError: cannot import name to_sql
Does anyone have any ideas? Cheers
You should definitely upgrade to pandas 0.16.0:
sudo pip install -U pandas
I just looked through the source code of pandas/io/sql.py in 0.13.1 and 0.16.0, and the to_sql() and read_sql() methods are not present in the older version, while they exist in the latest version.
To summarize our conversation in the comments, in order to successfully build pandas, you will need to install the gcc, g++, and python-dev packages from your system's package manager (apt-get, yum, zypper, whatever). If you are building for Python 3, the python3-dev package is needed.
If you are using Windows and the standard python.org version of Python, the easiest way to keep your packages up to date is to use Christoph Gohlke's Python Extension Packages for Windows repository. Many packages depend on his MKL-linked version of numpy, including pandas. The nice thing about all of these packages is that they are pre-compiled against both 32- and 64-bit versions of Python, and are generally available for Python 2.7, 3.3, and 3.4 (depending on the package, of course - some haven't been ported to Py3 yet). They are available in .whl format, so installation/upgrading is as easy as
pip install -U name_of_package.whl

Categories

Resources