Installing bioinformatics packages like bowtie2 in windows through WSL - python

I'm trying to develop a GUI in python for analyze tRNA-Seq data which could be run in Linux and Windows. For this it is needed run some programs like: bowtie2, samtools or bedtools, which can be downloaded by anaconda easily on Linux but is a headache on Windows. This programs can't be downloaded on Windows so I had to install Windows Subsystem for Linux (WSL) and tried to downloaded by this way.
I have developed the following python script (anaconda_setup.py) for doing this:
import os
#Download the file for Linux, altough this script will run only on Windows Subsystem for Linux
os.system('curl -O https://repo.anaconda.com/archive/Anaconda3-2020.07-Linux-x86_64.sh')
#Checking the integrity of the file
os.system('sha256sum Anaconda3-2020.07-Linux-x86_64.sh')
#Running the .sh script
os.system('bash Anaconda3-2020.07-Linux-x86_64.sh')
#Compiling from source
os.system('source ~/.bashrc')
os.system('Anaconda3-2020.07-Linux-x86_64.sh')
#Using conda to install bowtie2, samtools and bedtools
os.system('conda install -c bioconda bowtie2')
os.system('conda install -c bioconda samtools')
os.system('conda install -c bioconda bedtools')
And then I use the following code in the main script for call the other script:
import os
...
os.system("wsl python3 anaconda_setup.py")
With this anaconda is installed correctly, but I'm not sure if it is installed on windows or in WSL. But I obtained the next error:
sh: 1: source: not found
sh: 1: conda: not found
sh: 1: conda: not found
sh: 1: conda: not found
On the other hand I have entered to WSL from CMD and I can run conda.exe and conda manually, but I can't do it in an automatically way. Moreover from CMD I can't run: "wsl conda" (error: /bin/bash: conda: command not found) but I can run wsl conda.exe without anyproblem.
Any idea what I'm doing wrong or how can I fix this?
Thank you very much.

Use Linux installers for anaconda to install anaconda for wsl2
wget https://repo.anaconda.com/miniconda/Miniconda3-py39_4.9.2-Linux-x86_64.sh
check if conda command runs, if not, the path must be exported in .bashrc file
export PATH=/home/user/anaconda3/bin:$PATH
run conda again, it will work now. You can install your required software using conda in wsl2.
Hope this helps you out. For more info visit this
post

Here are the steps you can follow.
you have to have Ubuntu terminal installed. If not download it from Microsoft Store.
After installing Ubuntu install wget using command sudo apt install wget
Install miniconda because miniconda is lighter version of anaconda and will save up a lot of space.
Download miniconda installer.
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
Install miniconda bash Miniconda3-latest-Linux-x86_64.sh
export PATH export PATH=~/miniconda3/bin:$PATH
Install bowtie2 using bioconda channel conda install -c bioconda bowtie2

Related

wget not recognized in Jupyter through Anaconda

I'm using a Jupyter notebook through Anaconda.
I have a command: ! wget https://url
I get the error:
'wget' is not recognized as an internal or external command, operable
program or batch file.
I already tried installing wget on my local Anaconda (as I expected, it doesn't work)
Thanks
wget is a free software package for retrieving files using HTTP, HTTPS and FTP, the most widely-used internet protocols. To install wget in Anaconda run:
conda install -c anaconda wget
If that doesn't work try:
conda install -c menpo wget
Anaconda should have added jupyter to your PATH automatically during the installation if you selected that option. If you did not select it, you need to do this manually by following the steps in answers to Anaconda Packages.

Spyder IDE plugins installation (spyder-unittest)

I am trying to install a plugin for the Spyder ide called spyder-unittest (description here).
I am using:
MacOS X Version 10.14.6
Anaconda Navigator 1.9.7
Spyder 3.3.6
Python 3.7
After a first attempt using the command
conda install -c spyder-ide spyder-unittest
the plugin did not work (i.e. the additional command Run unit tests was not available under the Run menu).
I also tried, without success:
conda install -c conda-forge spyder-unittest
I then uninstalled and installed once again Anaconda navigator, and tried conda install -c spyder-ide spyder-unittest. This time, I got a very lengthy output, indicating conflicts (please see image):
Now, I do not know what to do. Could someone please offer any help?
I also tried to install after going, through the Terminal, to the directory where I thought the Spyder plugins were installed. Same output as above.
Thank you very much in advance.
Cheers,
Orlando
I managed to install spyder-unittest without any errors on my computer.
I suggest creating a new environment to avoid any conflicts with other packages when installing.
First create a new environment using:
conda create --name env python=3.7
After creating the environment, activate it using conda activate env
Then install spyder-unittest using conda install -c conda-forge spyder-unittest

installing xgboost on Python - channel not found [duplicate]

I am a new Python user. I downloaded the latest Anaconda 3 2.4.1 (Python 3.5) from the below link:
https://www.continuum.io/downloads
My PC Configurations are: Windows 10, 64 bit, 4GB RAM
I have spent hours trying to find the right way to download the package after the 'pip install xgboost' failed in the Anaconda command prompt but couldn't find any specific instructions for Anaconda.
Can anyone help on how to install xgboost from Anaconda?
The easiest way (Worked for me) is to do the following:
anaconda search -t conda xgboost
You will get a list of install-able features like this:
for example if you want to install the first one on the list mndrake/xgboost (FOR WINDOWS-64bits):
conda install -c mndrake xgboost
If you're in a Unix system you can choose any other package with "linux-64" on the right.
Update on 22/10/2020:
Without searching in conda list of channels, you can install it using (source: https://anaconda.org/anaconda/py-xgboost) :
conda install -c anaconda py-xgboost
Anaconda's website addresses this problem here: https://anaconda.org/anaconda/py-xgboost.
conda install -c anaconda py-xgboost
This fixed the problem for me with no problems.
Download package from this website.
I downloaded xgboost-0.6-cp36-cp36m-win_amd64.whl for anaconda 3 (python 3.6)
Put the package in directory C:\
Open anaconda 3 prompt
Type cd C:\
Type pip install C:\xgboost-0.6-cp36-cp36m-win_amd64.whl
Type conda update scikit-learn
After trying some things the only thing that worked for me is:
conda install -c anaconda py-xgboost
I was able to install xgboost for Python in Windows yesterday by following this link. But when I tried to import using Anaconda, it failed. I recognized this is due to the fact that Anaconda has a different Python distribution. I then searched again and found this great article which made it!
The trick is after installing successfully for regular Python, to have it work for Anaconda, you just need to pull up the Anaconda prompt and cd into this folder "code\xgboost\python-package", then run:
python setup.py install
And voila! The article says you need to add the path, but for me it worked directly. Good luck!
Also copied below the original contents in case the link is not available...
Once the last command completes the build is done. We can now install
the Python module. What follows depends on the Python distribution
you are using. For Anaconda, I will simply use the Anaconda prompt,
and type the following in it (after the prompt, in my case [Anaconda3]
C:\Users\IBM_ADMIN>):
[Anaconda3] C:\Users\IBM_ADMIN>cd code\xgboost\python-package
The point is to move to the python-package directory of XGBoost. Then type:
[Anaconda3] C:\Users\IBM_ADMIN\code\xgboost\python-package>python setup.py install
We are almost done. Let's launch a notebook to test XGBoost.
Importing it directly causes an error. In order to avoid it we must
add the path to the g++ runtime libraries to the os environment path
variable with:
import os
mingw_path = 'C:\\Program Files\\mingw-w64\\x86_64-5.3.0-posix-seh-rt_v4-rev0\\mingw64\\bin'
os.environ['PATH'] = mingw_path + ';' + os.environ['PATH']
We can then import xgboost and run a small example.
import xgboost as xgb
import numpy as np
data = np.random.rand(5,10) # 5 entities, each contains 10 features
label = np.random.randint(2, size=5) # binary target
dtrain = xgb.DMatrix( data, label=label)
dtest = dtrain
param = {'bst:max_depth':2, 'bst:eta':1, 'silent':1, 'objective':'binary:logistic' }
param['nthread'] = 4
param['eval_metric'] = 'auc'
evallist = [(dtest,'eval'), (dtrain,'train')]
num_round = 10
bst = xgb.train( param, dtrain, num_round, evallist )
bst.dump_model('dump.raw.txt')
We are all set!
I'm able to install using the following commands (in Windows 10) :
conda install -c mikesilva xgboost
conda install -c conda-forge xgboost
GUYS ITS NOT THAT EASY:-
PLEASE FOLLOW BELOW STEP TO GET TO MARK
So here's what I did to finish a 64-bit build on Windows:
Download and install MinGW-64: sourceforge.net /projects/mingw-w64/
On the first screen of the install prompt make sure you set the Architecture to x86_64 and the Threads to win32
I installed to C:\mingw64 (to avoid spaces in the file path) so I added this to my PATH environment variable: C:\ mingw64 \ mingw64 \ bin(Please remove spaces)
I also noticed that the make utility that is included in bin\mingw64 is called mingw32-make so to simplify things I just renamed this to make
Open a Windows command prompt and type gcc. You should see something like "fatal error: no input file"
Next type make. You should see something like "No targets specified and no makefile found"
Type git. If you don't have git, install it and add it to your PATH.
These should be all the tools you need to build the xgboost project. To get the source code run these lines:
cd c:\
git clone --recursive https://github.com/dmlc/xgboost
cd xgboost
git submodule init
git submodule update
cp make/mingw64.mk config.mk
make -j4
Note that I ran this part from a Cygwin shell. If you are using the Windows command prompt you should be able to change cp to copy and arrive at the same result. However, if the build fails on you for any reason I would recommend trying again using cygwin.
If the build finishes successfully, you should have a file called xgboost.exe located in the project root. To install the Python package, do the following:
cd python-package
python setup.py install
Now you should be good to go. Open up Python, and you can import the package with:
import xgboost as xgb
To test the installation, I went ahead and ran the basic_walkthrough.py file that was included in the demo/guide-python folder of the project and didn't get any errors.
if you found an issue when you try to import xgboost (my case it is Windows 10 and anaconda spyder) do the following:
Click on the windows icon (start button!)
Select and expand the anaconda folder
Run the Anaconda Prompt (as Administrator)
Type the following command as it is mentioned in https://anaconda.org/anaconda/py-xgboost
conda install -c anaconda py-xgboost
That's all...Good luck.
You can download the xgboost package to your local computer, and you better place the xgboost source file under D:\ or C:\ (ps: download address: http://www.lfd.uci.edu/~gohlke/pythonlibs/#xgboost, and select "xgboost-0.6-cp35-cp35m-win_amd64.whl",but it is up to your operation system), and you open the Anaconda prompt, type in pip install D:\xgboost-0.6-cp35-cp35m-win_amd64.whl, then you can successful install xgboost into your anaconda
Try running this on Anaconda prompt
pip install xgboost
This worked for me on Spyder with Python 3.5
I figured out easy way to install XgBoost by mix of what is mentioned here.
Step 1:
Install gitbash from here and start gitbash.
Step 2: git clone --recursive https://github.com/dmlc/xgboost
Step 3: git submodule init
git submodule update
step 4: alias make='mingw32-make'
step 5: cp make/mingw64.mk config.mk; make -j4
step 6: Goto Anaconda prompt and if you have a conda environment then activate that environment like my was py35 so I activate it by typing activate py35
cd python-package
python setup.py install
step 7: setup the Path in system environment variable to the path where you installed xgboost/python-package.
Use this in your conda prompt:
python -m pip install xgboost
The following worked for me:
conda install libxgboost
The package directory states that xgboost is unstable for windows and is disabled:
pip installation on windows is currently disabled for further invesigation, please install from github.
https://pypi.python.org/pypi/xgboost/
Anaconda3 version 4.4.0check image
Go to Anaconda -> Environments -> from the dropdown select not installed -> If you can see xgboost pr Py-xgboost select and click apply.
There are a lot of dependencies of anaconda that have changed over the past years and won't work if you used them now. Some of the answers need serious updation.
I found this command did the job for me :
conda install -c conda-forge xgboost
You may also want to look at the official documentation of anaconda for xgboost:
https://anaconda.org/conda-forge/xgboost
I have used this command and it worked for me.
import sys
!{sys.executable} -m pip install xgboost
Open anaconda prompt and run
pip install xgboost
You can install it using pip:
pip3 install --default-timeout=100 xgboost
This simple helped me you don't have to include anything at the end because if you include something, some of your packages will be upgraded but some will be downgraded.
You can get this from this url: https://anaconda.org/anaconda/py-xgboost
conda install -c anaconda py-xgboost
Look here https://github.com/Rafi993/xgboost/ for building xgboost on your machine. There are many different varieties of the solution above, but it seems that the version in the link above is the good one. At least that worked for me: I've tested it on Windows 7 and Windows Server 2008.
Then run the following commands in cmd in order to install python bindings:
cd python-package
python setup.py install
You might also need a proper mingw (google for tdm-gcc)
and the latest setuptools from anaconda.
I hope it will help

Not able to install CyLP on windows

I am trying to install CyLP. I downloaded the cbc package.Then it says to run the following commands:
$ ./configure
$ make
$ make install
But these commands do not run in command prompt.So, how do I run them.Also, I tried the following command for pip install:
pip install -i https://pypi.anaconda.org/pypi/simple cylp
But, it gave me the error that cbc files were not found found.So , how do I install CyLP in windows.
I have recently worked with cylp package but on linux. So I am not sure that it is available for windows but there can be a quick fix to this problem on windows.
For working of make and make install on windowsHere are a few ports of GNU tools to Windows:
GnuWin32 - http://gnuwin32.sourceforge.net/summary.html
Gnu Tools for NT - http://www.devhood.com/Tools/tool_details.aspx?tool_id=3
GNU Utilities for Win32 - http://unxutils.sourceforge.net/
For working of ./configure on windows - I would install the MINGW/MSYS development tools and see if the configure script is happy in that environment.
EDIT
Okay So I finally came up with the solution on how to install CYLP on windows. I would recommend you to:
Try the following
Create a new environment for 32bit Python 2.7:
set CONDA_FORCE_32BIT=1
conda create -n py27_32 python=2.7
Activate it:
set CONDA_FORCE_32BIT=1
activate py27_32
install cylp:
conda install scipy
pip install cylp

Installing Python3 on Mac OS X Yosemite

I'm trying to install Python3 on a Mac OS X Yosemite, and did that by running the following command:
$ brew install python3
When I tried that, I got the following error:
clang: error: unable to find utility "clang", not a developer tool or in PATH
otool: error: unable to find utility "otool", not a developer tool or in PATH
Error: Failure while executing: /usr/bin/otool -L /usr/bin/install_name_tool
How can I fix this issue?
Thanks.
Try brew update and then brew doctor first. The doctor diagnoses common issues.
Seems something's wrong with your Xcode/Command Line Tools. This answer might be helpful.
I would highly recommend using the anaconda distribution, in particular miniconda.
For OSX Yosemite, this is a link to the Python 3.4 64-bit installer.
After downloading the application, open a terminal window, navigate to where you downloaded the app (e.g. cd ~/Downloads) and type:
bash Miniconda-latest-MacOSX-x86_64.sh
Now close and re-open your terminal window for the changes to take effect.
To test your installation, enter the command conda list from the terminal. If installed correctly, you will see a list of packages that were installed.
From here, you should be able to follow the on-screen instructions. If you get lost, you can refer to their installation guide.
After installing conda, you need to create an environment. To install an new environment named py3 with Python 3:
conda create --name py3 python=3
To activate this environment:
source activate py3
Here, I normally install iPython, iPython notebook and pyqt:
conda install ipython, ipython-notebook, pyqt
Now, to activate an ipython shell from within your environment:
ipython qtconsole
Although this reply does not attempt fix the homebrew issue, it answers the question of how to install Python3 on Mac OS X Yosemite.
Open Terminal and
[Try]: brew update
[or Homebrew Install]: /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
(code source found at https://brew.sh/)
Make sure processes finish, and then [Re-Try]: brew install python3
For me, I ran brew doctor which said
Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
pandoc
heroku
numpy
unbound
python#3.8
So I ran brew link python#3.8
And immediately after, python3 suddenly works!

Categories