Version of pip package diamond can't be called, neither by --version nor by other packages - pip

I need the pip package 'diamond' as a prerequisite for another package (humann3), however something doesn't work.
When I try to start humann3 it returns
CRITICAL ERROR: Can not call software version for diamond
So I try to check my diamond version with "diamond --version" but it returns
user#server:~$ diamond --version File
"/home/user/.local/bin/diamond", line 113
print "Diamond version %s" % (get_diamond_version())
^
SyntaxError: invalid syntax
It's supposed to be version 4.0.515, I just uninstalled it and reinstalled it. No change.
The OS is Debian GNU/Linux 10 (buster), it's my college's computer, I can't change it. But I have permission to install and unistall packages.
Also I realized that if I use different python versions to run it directly, I get different errors.
Python 3 returns the same error:
(base) user#server:~$ python3 .local/bin/diamond
File ".local/bin/diamond", line 113
print "Diamond version %s" % (get_diamond_version())
^
SyntaxError: invalid syntax
Python 2 returns another one:
(base) user#server:~$ python2 .local/bin/diamond
Traceback (most recent call last):
File ".local/bin/diamond", line 24, in <module>
from diamond.server import Server
ImportError: No module named diamond.server

Python 3 returns the same error:
(base) user#server:~$ python3 .local/bin/diamond
File ".local/bin/diamond", line 113
print "Diamond version %s" % (get_diamond_version())
^
SyntaxError: invalid syntax
The code print "" is for Python 2 only, in Python 3 it is SyntaxError. The problem was fixed in the Github repository but the code was not released to PyPI. To us it under Python 3 you need to install it from Github. First install git if you haven't installed it yet and the run
pip install -U git+https://github.com/python-diamond/Diamond.git
Python 2 returns another one:
(base) user#server:~$ python2 .local/bin/diamond
Traceback (most recent call last):
File ".local/bin/diamond", line 24, in <module>
from diamond.server import Server
ImportError: No module named diamond.server
You've installed the module only for Python 3, you cannot run it under Python 2. To run it under Python 2 you need to install it with Python 2:
python2 -m pip install -U diamond
But then you will also need to install everything (including humann3) under Python 2.

Related

Installing Octave Symbolic Package using SymPy (macOS) - Can't get SymPy to work

So, I've installed the Octave Symbolic Package from here:
https://sourceforge.net/p/octave/symbolic/ci/master/tree/
In the Octave command window I typed:
pkg install -forge symbolic
After the install I ran a test (as shown in link above) by typing:
pkg load symbolic
syms x
However, I got an following error with syms x.
Symbolic pkg v2.8.0: Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named sympy
error: Python cannot import SymPy: have you installed SymPy?
Try "sympref diagnose" for more information.
error: called from
assert_have_python_and_sympy at line 123 column 7
python_ipc_popen2 at line 79 column 5
python_ipc_driver at line 59 column 13
python_cmd at line 163 column 9
valid_sym_assumptions at line 38 column 10
assumptions at line 82 column 7
syms at line 97 column 13
Next, I visited the following site to install SymPy (which says to install Anaconda).
https://docs.sympy.org/latest/install.html#anaconda
So, then I go to the following site and download the graphical installer for macOS (Python 2.7 version).
https://www.anaconda.com/distribution/#download-section
Then I tested from the macOS terminal to see if Anaconda is installed using this command
conda --version
which returns conda 4.7.11.
I also typed
conda list
which returns (among a long list). sympy 1.4 py27_0.
So, it appears that SymPy is installed (at least at the terminal).
Next, I go back to the command line of Octave and typed:
sympref diagnose
Here is the output:
Symbolic package diagnostics
============================
Python and SymPy are needed for most features of the Symbolic package.
The Python interpreter is currently: "python".
Computers may have more than one Python interpreter installed. If you
need to, you can select a different one using the PYTHON environment
variable (see "help sympref"). For example, to use Python 3, try
setenv PYTHON python3
sympref reset
Attempting to run python -c "print(\"Python says hello\")"
status = 0
output = Python says hello
Good, Python ran correctly.
Python version
--------------
Let's check what version of Python we are calling...
Attempting to run python -c "import sys; print(sys.version)"
status = 0
output = 2.7.15 (default, Feb 5 2019, 12:31:36)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
SymPy Python Library
--------------------
SymPy is a Python library used by Symbolic for almost all features.
Attempting to run python -c "import sympy; print(sympy.__version__)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named sympy
status = 1
output =
Unfortunately status was non-zero: probably Python cannot import sympy.
* Is there an error message above?
* Do you have SymPy installed? If not, please try to install it and
try again.
* If you do have SymPy installed, maybe it's installed for a different
Python interpreter than the one we found? Please try "setenv" as
described above to change your python interpreter.
Octave doesn't have access to SymPy.
Any idea what I did wrong?
Try running these in octave...
setenv PYTHON /usr/local/anaconda3/bin/python
pkg load symbolic
/usr/local/anaconda3/bin was where all my anaconda bits were installed,
including a version of python. Yours may differ.
sympref diagnose then passes for me.
You will have to do this every time you start 'octave' before using the symbolic package, but it should be safe.

How to debug pip install <package name>

If I want to debug the setup.py file of my package packagename getting installed via "pip install packagename" , is there a way to do so? I have tried downloading the source, adding set_trace() in setup.py and run:
pip install .
However, as soon I get pdb() prompt, the install fails with error:
processing /Users/skauser/python-ibmdb/IBM_DB/ibm_db
Complete output from command python setup.py egg_info:
> /private/var/folders/b6/pmddncpn77550p8_g9kkx9f40000gp/T/pip-req-build-_fg8s5a2/setup.py(31)<module>()
-> machine_bits = 8 * struct.calcsize("P")
(Pdb)
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/b6/pmddncpn77550p8_g9kkx9f40000gp/T/pip-req-build-_fg8s5a2/setup.py", line 31, in <module>
machine_bits = 8 * struct.calcsize("P")
File "/private/var/folders/b6/pmddncpn77550p8_g9kkx9f40000gp/T/pip-req-build-_fg8s5a2/setup.py", line 31, in <module>
machine_bits = 8 * struct.calcsize("P")
File "/Library/anaconda3/lib/python3.7/bdb.py", line 88, in trace_dispatch
return self.dispatch_line(frame)
File "/Library/anaconda3/lib/python3.7/bdb.py", line 113, in dispatch_line
if self.quitting: raise BdbQuit
bdb.BdbQuit
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/b6/pmddncpn77550p8_g9kkx9f40000gp/T/pip-req-build-_fg8s5a2/
Although I can debug the source via: python setup.py build, the behavior that I want to debug is applicable when installed through pip.
Pip is a python program. You can see it's content with cat $(which pip). Then you can copy it to a new file in your project's directory. For example, here is how it looks like for me:
File mypip.py:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re
import sys
from pip._internal.cli.main import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
Then you can add a breakpoint with pdb or use PyCharm as mentioned in the answer from Igor Yudnikov.
For reference, this is how it to looks like in my Pycharm
Oh! Just found a solution, its pretty easy. What is pip? It's a plain python file, which is I think somehow bound to run via python, and under the hood system makes something like
python pip install ...
so, at first we need to know where is pip
which pip
says
/Users/me/PycharmProjects/etlscripts/venv/bin/pip
So, we may go to Pycharm, create config like
then you'll be able to catch your exception. Cheers.

Scipy installation windows 10

I have some difficulties trying to install Scipy for Python 3.5 on a Windows 10 machine and I hope I can find some help here. So here is what I have done so far.
I have downloaded the numpy+mkl for python 3.5 and 64bit version as well as the scipy0.18.1 for the same versions, from Gohlke's website
I installed the numpy+mkl whl with:
python -m pip install numpy-1.11.2+mkl-cp35-cp35m-win_amd64.whl
all goes well.
then I install the scipy package the same way like:
python -m pip install scipy-0.18.1-cp35-cp35m-win_amd64.whl
This also completes.
However, when I try to run python afterwards I get the following error:
Fatal Python error: Py_Initialize: can't initialize sys standard streams
Traceback (most recent call last):
File "C:\Python35\Lib\site-packages\scipy\io\__init__.py" , line 97, in <module>
File "C:\Python35\Lib\site-packages\scipy\io\matlab\__init__.py", line 13 in <module>
File "C:\Python35\Lib\site-packages\scipy\io\matlab\mio.py", line 8 in <module>
ImportError: No module named 'numpy'
I also get a pop-up that Python has stopped working.
I have tried a different order in which I installed the packages, but all lead to the error mentioned when Scipy is installed.
I also installed did this on a windows 7 machine and there it works.
Does anybody have any idea what causes this issue?
I also had some issues. So I just installed Anaconda3 insted of python directly.

Can't create virtualenv using Python 3.2. Whodunnit? Pip or setuptools or Python 2.7?

I can't properly install a Python 3.2 based virtual environment using virtualenvwrapper. I have hit a mystery wall and now I am looking for more options to solve my WHODUNNIT? predicament.
Some background
I first tried to install virtualenvwrapper using pip 1.5.6 from Python 2.7 (system's Python default). When I was trying to uninstall/upgrade my pip somehow I broke it. Now if I try:
$ pip
Traceback (most recent call last):
File "/usr/local/lib/python3.2/dist-packages/distribute-0.6.28-py3.2.egg/pkg_resources.py", line 2816, in <module>
working_set.require(__requires__)
File "/usr/local/lib/python3.2/dist-packages/distribute-0.6.28-py3.2.egg/pkg_resources.py", line 690, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/local/lib/python3.2/dist-packages/distribute-0.6.28-py3.2.egg/pkg_resources.py", line 592, in resolve
raise VersionConflict(dist,req) # XXX put more info here
pkg_resources.VersionConflict: (pip 7.1.2 (/usr/local/lib/python3.2/dist-packages), Requirement.parse('pip==1.5.6'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python3.2/dist-packages/distribute-0.6.28-py3.2.egg/pkg_resources.py", line 2820, in <module>
parse_requirements(__requires__), Environment()
File "/usr/local/lib/python3.2/dist-packages/distribute-0.6.28-py3.2.egg/pkg_resources.py", line 588, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==1.5.6
However, I managed to install PIP3.2.
$ pip3.2 --version
pip 7.1.2 from /usr/local/lib/python3.2/dist-packages (python 3.2)
So I proceeded to install virtualenvwrapper with no problem:
$ sudo pip3.2 install virtualenvwrapper
This is where Python 3.2 resides
$ whereis python3.2.3
whereis python3.2.3
python3.2: /usr/bin/python3.2 /etc/python3.2 /usr/lib/python3.2 /usr/bin/X11/python3.2 /usr/local/lib/python3.2 /usr/include/python3.2 /opt/Python-3.2/bin/python3.2 /usr/share/man/man1/python3.2.1.gz
This is my virtualenv version:
$ virtualenv --version
14.0.6
Error
Before making a virtualenv I modified my .bashrc
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/admin/workspace
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh
After sourcing it (i.e. source ~/.bashrc) I just can't manage to start a virtualenv.
$ mkvirtualenv --python=/usr/bin/python3.2 venv
Running virtualenv with interpreter /usr/bin/python3.2
New python executable in /home/admin/.virtualenvs/venv/bin/python3.2
Also creating executable in /home/admin/.virtualenvs/venv/bin/python
/usr/local/lib/python3.2/dist-packages/virtualenv-14.0.6-py3.2.egg/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/_vendor/pkg_resources/__init__.py:87: UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here.
Traceback (most recent call last):
File "/usr/local/lib/python3.2/dist-packages/virtualenv-14.0.6-py3.2.egg/virtualenv.py", line 2304, in <module>
main()
File "/usr/local/lib/python3.2/dist-packages/virtualenv-14.0.6-py3.2.egg/virtualenv.py", line 705, in main
symlink=options.symlink)
File "/usr/local/lib/python3.2/dist-packages/virtualenv-14.0.6-py3.2.egg/virtualenv.py", line 924, in create_environment
download=download,
File "/usr/local/lib/python3.2/dist-packages/virtualenv-14.0.6-py3.2.egg/virtualenv.py", line 843, in install_wheel
cert_data = pkgutil.get_data("pip._vendor.requests", "cacert.pem")
File "/usr/lib/python3.2/pkgutil.py", line 573, in get_data
loader = get_loader(package)
File "/usr/lib/python3.2/pkgutil.py", line 461, in get_loader
return find_loader(fullname)
File "/usr/lib/python3.2/pkgutil.py", line 471, in find_loader
for importer in iter_importers(fullname):
File "/usr/lib/python3.2/pkgutil.py", line 427, in iter_importers
__import__(pkg)
File "/usr/local/lib/python3.2/dist-packages/virtualenv-14.0.6-py3.2.egg/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/__init__.py", line 15, in <module>
After the error if I type...
$ workon
$
Funny thing is the venv is created in .virtualenvs
Possible causes
Reading elsewhere in the web (I found just one person having a similar problem) it could be solved using a previous version of virtualenv (I tried that to no success), or maybe I'm using an incorrect combination of pip and/or virtualenv and/or virtualenvwrapper. Or perhaps it's my Python2.7 messing around in the background.
UPDATE: Setuptools
Or what about setuptools? Apparently it has to do. I was getting this error when trying with PIP 1.5.6
UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here.
warnings.warn(msg)
ANOTHER UPDATE: Fixed the original pip
I managed to fix original pip using:
$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python get-pip.py
$ pip --version
pip 8.0.3 from /usr/local/lib/python2.7/dist-packages (python 2.7)
UPDATE: Virtualwrapper isn't!
In my own 'Whodunnit' saga I'd say virtualwrapper has nothing to do. Here:
$ virtualenv -p /usr/bin/python3.2 ~/.virtualenvs/venv32
Running virtualenv with interpreter /usr/bin/python3.2
New python executable in /home/admin/.virtualenvs/venv32/bin/python3.2
Also creating executable in /home/admin/.virtualenvs/venv32/bin/python
/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-8.0.2-py2.py3-none-any.whl/pip/_vendor/pkg_resources/__init__.py:87: UserWarning: Support for Python 3.0-3.2 has been dropped. Future versions will fail here.
But problem still persists. What else could I try?
Thanks in advance!
You must use pip < 8 and virtualenv < 14 if you want to use Python 3.2. See also https://virtualenv.pypa.io/en/latest/changes.html#id7
Why do you need to use ancient Python 3.2? The best thing you can do would be to install and use the far superior Python >= 3.4 instead.

HTTPLIB2 Error installing python-twitter on mac osx

Hello I am trying to install python-twitter and one of the dependencies HTTPLIB2 is giving me a lot of problems. I have searched the internet up and down but maybe I do not know what the right key words are. Here is the problem.
I am installing python-twitter. I install the requirements either by "pip install -r requirements.txt" or doing them one by one through for example "pip install httplib2". Then I run "python setup.py install". It's happy but then "python setup.py test" fails as followed with an error on import HTTPLIB2.
python setup.py test
running test
running egg_info
writing requirements to python_twitter.egg-info/requires.txt
writing python_twitter.egg-info/PKG-INFO
writing top-level names to python_twitter.egg-info/top_level.txt
writing dependency_links to python_twitter.egg-info/dependency_links.txt
reading manifest file 'python_twitter.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching '.DS_Store'
writing manifest file 'python_twitter.egg-info/SOURCES.txt'
running build_ext
Traceback (most recent call last):
File "setup.py", line 73, in <module>
Main()
File "setup.py", line 66, in Main
setuptools.setup(**METADATA)
File
....
<deleted these parts to save space>
module = __import__('.'.join(parts_copy))
File "/Users/ME/Downloads/python-twitter-1.0/twitter_test.py", line 30, in <module>
import twitter
File "/Users/ME/Downloads/python-twitter-1.0/twitter.py", line 65, in <module>
import oauth2 as oauth
File "/usr/local/lib/python2.7/site-packages/oauth2/__init__.py", line 32, in <module>
import httplib2
File "/usr/local/lib/python2.7/site-packages/httplib2/__init__.py", line 347
print('%s:' % h, end=' ', file=self._fp)
^
SyntaxError: invalid syntax
But I thought the print error was an incompatibility between python 2 and 3. Why am I getting this while I clearly have python 2.7 (I checked and uninstalled and reinstalled HTTPLIB2).
Thanks much for your help
i had a same issue. It seems to be python2.7 and 3.x version conflict issue and resolved by
python2.7 -m pip install -t lib/ -r requirements.txt
Just in case, this happens when you install httplib2 with a python3 version of pip and then execute it with python2.
This happens for example when creating manually an environment with:
pip install -t lib/ -r requirements
As it happens when creating an AppEngine standard environment vendor folder.
This happens because contrary to most of the libraries, httplib2 has completely different versions for python2 and python3.

Resources