scikit-bio not working after installation - python

I have installed scikit-bio on my mac and when I run python -m skbio.test, I get the following error:
File "/macqiime/anaconda/lib/python2.7/site-packages/skbio/io/tests/test_util.py", line 17, in <module>
import httpretty
ImportError: No module named httpretty.
Could this be based on my PATH?
-macqiime is in the directory Users.

Edit: Changed my answer to use conda instead of pip
Try executing:
conda install -c https://conda.anaconda.org/hargup httpretty

Related

No module named 'geopy'

I am trying to install geopy in a virtual environment created by miniconda. When I do pip install geopy, it gives me this:
(finalenv) MacBook-Pro ~ % pip install geopy
Requirement already satisfied: geopy in /usr/local/Caskroom/miniconda/base/envs/finalenv/lib/python3.6/site-packages (2.2.0)
Requirement already satisfied: geographiclib<2,>=1.49 in /usr/local/Caskroom/miniconda/base/envs/finalenv/lib/python3.6/site-packages (from geopy) (1.52)
The python version for this Finalenv is Python 3.6.13 :: Anaconda, Inc.
However, when I try to run my script:
import psycopg2
import geopy
I get an error that:
(finalenv) MacBook-Pro ~ % /usr/local/bin/python3 /Users/s/Desktop/s-project/v2.py
Traceback (most recent call last):
File "/Users/s/Desktop/s/file.py", line 15, in <module>
import geopy
ModuleNotFoundError: No module named 'geopy'
what am I missing here?
Since you are using Anaconda, you can try installing it through conda to see if the installation happens on the same folder. Open Anaconda CLI prompt as Administrator. You can try
conda config --add channels conda-forge
and
conda install -c conda-forge geopy.
/usr/local/bin/python3 is your OS python executable, not the one used by your virtualenv.
In order to run the script always with the python3 on the virtual environment (if it is activated), you can do this:
Add #!/usr/bin/env python3 at the beginning of the file. It will look like this:
#!/usr/bin/env python3
import psycopg2
import geopy
Give execution permissions to the file - in your case: chmod u+x v2.py
And run the file from the shell: ./v2.py

ModuleNotFoundError: No module named 'cryptography'

these are the Error messages I am geeting on running any of my project modules.
Traceback (most recent call last):
File "C:\Users\hsnl\BlockchainCodesTutor\Wallet.py", line 3, in <module>
import Transactions
File "C:\Users\hsnl\BlockchainCodesTutor\Transactions.py", line 2, in <module>
import Signatures
File "C:\Users\hsnl\BlockchainCodesTutor\Signatures.py", line 2, in <module>
import cryptography
ModuleNotFoundError: No module named 'cryptography'
I have already installed the cryptography module and was working perfectly until today I start getting this message that " No module named 'cryptography'".
I have again installed the cryptography as well as pip package but still showing the same error.
There might be loose versions running on your system. Please try the following:
python -m pip uninstall cryptography
python -m pip install cryptography
You can also check out this with python -m to make sure you are not using a loose pip.
You might not have cryptogtaphy installed correctly. I see you are using windows. Open commandline as an administrator and run pip install cryptography again. Enshure that the installation finishes without any errors and consider to restart your python interpreter after installation.
For further help you should post more details like the output of pip and your code leading to the error, so a more detailed answer for your problem can be given.
Try download cryptography whl from here.
Then use pip install cryptography-XXX.whl
For example:
pip install cryptography-3.3.1-cp36-abi3-win_amd64.whl
And now just supports python2.7 and python3.6.

ImportError: The 'packaging.requirements' package is required

I'm running VPS with ubuntu:
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty
I tried to upgrade Python to 2.7.16 from 2.7.6.
Just after upgrade Gunicorn library failed to start with
Traceback (most recent call last):
File "/home/user/bin/python-2.7/bin/gunicorn", line 7, in <module>
from gunicorn.app.wsgiapp import run
File "/home/user/bin/python-2.7/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 9, in <module>
from gunicorn.app.base import Application
File "/home/user/bin/python-2.7/lib/python2.7/site-packages/gunicorn/app/base.py", line 12, in <module>
from gunicorn import util
File "/home/user/bin/python-2.7/lib/python2.7/site-packages/gunicorn/util.py", line 12, in <module>
import pkg_resources
File "/home/user/bin/python-2.7/lib/python2.7/site-packages/pkg_resources/__init__.py", line 82, in <module>
__import__('pkg_resources.extern.packaging.requirements')
File "/home/user/bin/python-2.7/lib/python2.7/site-packages/pkg_resources/extern/__init__.py", line 61, in load_module
"distribution.".format(**locals())
ImportError: The 'packaging.requirements' package is required; normally this is bundled with this package so if you get this warning, consult the packager of your distribution.
I was told that it could be some setuptools issue, so I renewed them with
python -m ensurepip
Looking in links: /tmp/tmp98U8zf
Requirement already satisfied: setuptools in ./bin/python-2.7/lib/python2.7/site-packages (41.1.0)
Requirement already satisfied: pip in ./bin/python-2.7/lib/python2.7/site-packages (19.2.2)
(no changes)
I tried to do
pip install packaging
(no changes)
or downgrade setuptools to 19.2 (as suggested in Python 2.7 The 'packaging' package is required; normally this is bundled with this package)
and got
File "/home/user/bin/python-2.7/lib/python2.7/site-packages/gunicorn/config.py", line 8, in <module>
import copy
File "/home/user/bin/python-2.7/lib/python2.7/copy.py", line 52, in <module>
import weakref
File "/home/user/bin/python-2.7/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
Is there any working way to upgrade to 2.7.16 python in my case?
UPD:
I upgraded python with it with
wget https://www.python.org/ftp/python/2.7.16/Python-2.7.16.tgz
make clean && ./configure --enable-unicode=ucs4 --enable-shared --prefix=/home/user/bin/python-2.7/ --with-ensurepip=install && make && make install
pip install -r ~/django/django_projects/requirements.txt
pip freeze: https://www.pastiebin.com/5d592ea701503
Thanks.
Scenario
First: When trying to execute a Python script, the following error message appears:
ImportError: The 'packaging.requirements' package is required; normally this is bundled with this package so if you get this warning, consult the packager of your distribution.
Second: When trying to check the version of setuptools with pip show setuptools (or when using any other pip command), the next error message appears:
ImportError: cannot import name _remove_dead_weakref
Reason
This is because the current Python installation is somehow screwed up. In my case the mess was caused by an upgrade from Ubuntu 16.04 to Ubuntu 18.04.
Solution
With Virtual Environment
In the best case you were already using a virtual environment (this was my case). The solution here would be to recreate/setup your venv again (step-by-step):
$ cd /path/to/your/venv
# remove your old venv
$ rm -rf ./*
# create a new one
$ /usr/bin/virtualenv . --python=YOUR-PYTHON-VERSION
# activate venv
$ source bin/activate
# verify the correct python version is installed
$ python --version
For example replace YOUR-PYTHON-VERSION with python2.7 or python3.7.
After recreating your venv the problem should be fixed and you should be able to use pip again.
Without Virtual Environment
I think the best way to fix the problem would be to completely uninstall all non-default Python versions (for example Ubuntu 18.04 comes with Python 3.6+) and then make a clean reinstall of all other Python versions needed.
Try upgrading pip by typing:
pip install --upgrade pip

ModuleNotFoundError : no module named 'pycorenlp'

I need to install python wrapper for StanfordCoreNLP.
I have used git clone https://github.com/smilli/py-corenlp and also pip install pycorenlp and its showing success in both the cases, but when I run from pycorenlp import StanfordCoreNLP, its showing ModuleNotFoundError.
I checked its path if it installed or not. It is installed at "C:\Users\simra_000\Anaconda3\Lib\site-packages\pycorenlp" using pip
and using git clone also it is installed at "C:\Users\simra_000\py-corenlp"
from pycorenlp import StanfordCoreNLP
Traceback (most recent call last): File "", line 1, in
ModuleNotFoundError: No module named 'pycorenlp'
check if the module was installed by:
pip list
also you can add this code to install the module if it's not installed:
import pip
required_pkgs = ['pycorenlp']
installed_pkgs = [pkg.key for pkg in pip.get_installed_distributions()]
for package in required_pkgs:
if package not in installed_pkgs:
with suppress_stdout():
pip.main(['install', package])
also check the version of python that you are used to run the script and the version of pip, for example if you are using python3 and you install the module via pip (python2) the module was installed for python v.2 only
otherwise check the name of your script, so if the name of your script is pycorenlp.py the import will not work, and you need to change the name of your script
hope that helps you

Installing numpy, cython, cpython for Python 2.7.12

I have been trying to install numpy for Python 2.7.12 on a ubuntu 16.04 machine, but am not sure I am doing the right thing.
I issued the command
python setup.py install
and received the following error message:
ImportError: No module named Cython.Compiler.Main
So I have also been trying to install the cython package and received another error message:
/Cython-0.28.1/Cython/Plex/Scanners.c:19:20: fatal error: Python.h: No such file or directory
I thought this problem required me to install cpython. Trying to install this resulted in the following error message:
Traceback (most recent call last):
File "setup.py", line 4, in <module>
import sys, os, importlib.machinery, re, optparse
ImportError: No module named machinery
I am somewhat stumped about how to continue. Am I on the right path? Is there a different way I could try (the computer in question cannot connect to the internet)?
You can check if pip is install thanks to the command which pip,
in my case :
$ which pip
/home/usr1/anaconda3/bin/pip
If pip is not install install it : instruction here
then you should be able to use it such as :
pip install numpy
an alternative is to use : conda install
In the terminal use:
pip install numpy
If you get any error like 'permission denied', try:
sudo pip install numpy

Categories