Biopython - very basic questions about how to install - python

I'm trying to install Biopython but I've had some trouble. I've looked for an answer on the README, PDF manual and in other people's questions but they focus on more advanced problems while I'm still stuck at level 0.
I am a complete n00b so please, bear with me.
I have downloaded python3 and installed it on my Mac.
python3 --version
Python 3.7.3
pip3 --version
pip 19.2.3 from /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip (python 3.8)
I have then gone and downloaded biopython-1.77.tar.gz and uncompressed on my desktop.
From the biopython-1.77 folder, I did
python3 setup.py build
which I think worked OK (things moved on the screen). It was followed by
sudo python3 setup.py install
Likewise, I think this too worked.
Now, to test if the installation worked and if I'm ready to use Biopython I tried
python3
[>>>import Bio
but I get the error:
/Users/user/Desktop/biopython-1.77/Bio/__init__.py:126: BiopythonWarning: You may be importing Biopython from inside the source tree. This is bad practice and might lead to downstream issues. In particular, you might encounter ImportErrors due to missing compiled C extensions. We recommend that you try running your code from outside the source tree. If you are outside the source tree then you have a setup.py file in an unexpected directory: /Users/user/Desktop/biopython-1.77
BiopythonWarning,
I then tried to do this from elsewhere and I changed directory to the Python3.8 folder and tried
python3
[>>> import Bio
but I get the error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'Bio'
I've also tried to specify the path to Bio within biopython-1.77 but I get a SyntaxError: invalid syntax on the first "/" within the path.
Any help to install Biopython will be much appreciated.

Related

Unable to install MOSAIC on windows or Mac OS

I am trying to download and run some software I need to look at for my bachelor assignment.
However, the instructions on the website (https://pages.nist.gov/mosaic/html/doc/InstallWindows.html#id19) make me use my terminal. I have no experience using the terminal and am having issues.
The instructions made me install anaconda_ .
When installing the dependencies I found that even after adding the installation source (conda-forge) some dependencies are not found. I tried to install from a downloaded source distribution.
I put the unpacked zip in my MOSAIC folder but I am now getting an error when running the line:
$ python setup.py mosaic_deps
This results in:
traceback (most recent call last):
File "setup.py", line 2, in <module>
I have no idea how to fix this problem. If someone could have a look at it and explain that would really help me out.

Installing PIP Python 3.6.3 Ubuntu 16.04 Zlib Not Available, But It's Installed

I'm trying to follow this tutorial on installing Python 3.6.3 and PIP with virtual environments, but when I get to sudo python3.6 get-pip.py I get the error
Traceback (most recent call last):
File "get-pip.py", line 20061, in <module>
main()
File "get-pip.py", line 194, in main
bootstrap(tmpdir=tmpdir)
File "get-pip.py", line 82, in bootstrap
import pip
zipimport.ZipImportError: can't decompress data; zlib not available
but I have zlib1g-dev installed and don't know how to fix this problem. I've googled a lot and tried reinstalling, but haven't had any success.
Sorry to start a new question, but I did not have enough Karma to comment on the other one. Any help would be greatly appreciated.
Update: I ended up installing everything from source instead of using any packages and it seems to be working. I was not able to solve the problem, but found an alternative way to get things working.
For pip to work, Python needs to be linked to the zlib library when Python itself is installed. It appears that either zlib was not installed when you installed Python, or at least that the Python installer couldn't locate it. To help it along, you may issue the following before installing Python. In bash syntax,
zlib_lib="/usr/lib32"
zlib_inc="/usr/include"
export CPPFLAGS="-I${zlib_inc} ${CPPFLAGS}"
export LD_LIBRARY_PATH="${zlib_lib}:${LD_LIBRARY_PATH}"
export LDFLAGS="-L${zlib_lib} -Wl,-rpath=${zlib_lib} ${LDFLAGS}"
Here I've assumed that zlib is installed under /usr/lib32 and /usr/include/. To check this, look for the libz.so.1 file in the "lib" directory and the zlib.h file in the "inc" directory. If you find them somewhere else, simply change zlib_lib and zlib_inc accordingly.
IF you have different versions of Python installed it is likely the install is on another version. for example. I have pyperclip in 3.6.3 32bit version, but I an not access it in 3.6.3 64bit or 3.7.2dev.

virtualenvwrapper syntax error while setting up for python in powershell

At the moment I'm following this guide to set up python with the purpose of making a python scraper. I'm attempting to install Vitualenvwrapper which should be a simple pip command but I keep getting a syntax error. I have attempted the fixes listed (even though the one I have found don't list a syntax error as a problem). Can anyone shed some light on this for me?
$ C:\Users\nik> pip install virtualenvwrapper-powershell
Collecting virtualenvwrapper-powershell
Using cached virtualenvwrapper-powershell-12.7.8.zip
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\nik\AppData\Local\Temp\pip-build-c37hzy_b\virtualenvwrapper-powershell\setup.py", line 76
TOKEN_READ = 0x00020000L | 0x0008
^
SyntaxError: invalid syntax
Command "python setup.py egg_info" failed with error code 1 in C:\Users\nik\AppData\Local\Temp\pip-build-c37hzy_b\virtualenvwrapper-powershell\
The issue here is that its defaulting to using Python 3.x. You probably have a reference to Python3.x in your environment PATH.
Open System your machine, go to Advanced Settings -> Environment Variables and edit your PATH. Remove entries for Python3.x and leave the Python2.7 entries behind.
Open up PowerShell, type python, hit enter and verify that python 2.7 runs.
Re-run your command:
pip install virtualenvwrapper-powershell
Then you should find it all works.
Of course be aware that removing Python3.x from your path might affect other things that you may be using python3 for, so just remember the entries you removed in case in the future you find anything not working that relied on python3.

How to fix Python ValueError:bad marshal data?

Running flexget Python script in Ubuntu, I get an error:
$ flexget series forget "Orange is the new black" s03e01
Traceback (most recent call last):
File "/usr/local/bin/flexget", line 7, in <module>
from flexget import main
File "/usr/local/lib/python2.7/dist-packages/flexget/__init__.py", line 11, in <module>
from flexget.manager import Manager
File "/usr/local/lib/python2.7/dist-packages/flexget/manager.py", line 21, in <module>
from sqlalchemy.ext.declarative import declarative_base
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/ext/declarative/__init__.py", line 8, in <module>
from .api import declarative_base, synonym_for, comparable_using, \
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/ext/declarative/api.py", line 11, in <module>
from ...orm import synonym as _orm_synonym, \
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/__init__.py", line 17, in <module>
from .mapper import (
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/mapper.py", line 27, in <module>
from . import properties
ValueError: bad marshal data (unknown type code)
If you get that error, the compiled version of the Python module (the .pyc file) is corrupt probably. Gentoo Linux provides python-updater, but in Debian the easier way to fix: just delete the .pyc file. If you don't know the pyc, just delete all of them (as root):
find /usr -name '*.pyc' -delete
There also appears to have been some sort of regression in setuptools with use with python 3.7. See for an example - https://github.com/pypa/setuptools/issues/1257
Forcing reinstallation of setuptools fixed this issue for me.
sudo pip3 install --upgrade --force-reinstall setuptools
Just delete
/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/properties.pyc
it is corrupt as the text indicates. You'll probably have to do so as root.
After that start (again as root) run python (2.7):
/usr/bin/python -c "import sqlalchemy.orm.properties"
to recreate this .pyc file.
If you don't recreate the .pyc file, your program starts slower than necessary as the .py file takes longer to load than the .pyc (and a normal user cannot write the .pyc file).
This can happen if you have Python 2.7 .pyc files and you try to load them using Python 3.5. In my case this was a third-party tarball that erroneously included pre-compiled Python 2.7 .pyc files along with the source code.
I get this error in Ubuntu 18.04 Raspberry Pi 3 when I trying update my system typing sudo apt-get update and solve this error just typing:
sudo find /usr -name '*.pyc' -delete
This is remove all .pyc file in my system. Now I typing again sudo apt-get update && sudo apt-get upgrade and I get my update without thie error marshal-data
I resolved a similar error by un-installing and re-installing the Python application I was using, and all dependencies, using the system package manager.
In my case I was using awscli on Debian 9 and the error was "ValueError: bad marshal data (set size out of range)".
I ran as root:
apt-get purge awscli
apt-get autoremove
apt-get install awscli
And then the error was fixed.
I could imagine cases where the broken package might not get removed (for example because it was marked as manually installed, or was a dependency of another application still installed), in those cases this action may not resolve the error. However I thought I should try this way before manually deleting .pyc files the system installed, and I got lucky.
I also got this problem in Windows environment(win 10).
I fixed it by going to the Settings and repairing Python 3.7 with its installer.
Everything works fine since then.
As far as I could recall, I had kept a dash server running when my computer went to hibernation.
Maybe the damage was done in the hibernating process somehow.
I solved this problem by the following procedure :
In the error code message, you can see
from sqlalchemy.ext.declarative import declarative_base cause this error.
So just pip uninstall sqlalchemy and pip install sqlalchemy, problem solved.
It may be because of the damage of the library. Try re-install the package.
I had the same error in a conda environment which traced back to importing the matplotlib package.
simply pip uninstall matplotlib and then pip install matplotlib solved the problem.

Why do I have problems loading a module in Python3 but not in Python2?

Depending on which installation of Python I am using I have some problems to load a module. When I type
from quantecon import approx_markov
in the terminal using Python 3.4.0, the following error message is returned:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/quantecon/__init__.py", line 6,in <module>
from asset_pricing import AssetPrices
ImportError: No module named 'asset_pricing'
In the folder /usr/... as referred to above, I do however find a module called asset_pricing. (I have to admit that I additionally do not understand why the module asset_pricing interferes.)
I installed quantecon with:
pip3 install quantecon
I suspect that the problems are related to the Python version I am using. I also installed
pip install quantecon
and when I call the module approx_markov form the terminal, using Python 2.7.6 (I think this is the standard Python version of the OS I am using) I do not receive any error message. To solve the problem I already followed the instruction in the following discussion but to no avail Python3 has no acces to python2 modules (ubuntu).
The currently released version of quantecon is not Python 3 compatible; it uses relative imports and these are not supported anymore in Python 3.
The version in the source repository has been refactored and updated, and looks like it'll work with Python 3. You'll need to install that version instead:
pip3 install -U git+https://github.com/jstac/quant-econ.git
where -U tells pip3 to upgrade the package.
Note that there have been a lot of changes recently; use at your own risk. You could stick with Python 2 and wait for an official release.

Categories

Resources