from PyBioMed.PyMolecule import moe; ModuleNotFoundError: No module named 'rdkit' - python

I tried to install the pybiomed package by using this link:
1- Download the PyBioMed-1.0.zip
2- Extract the PyBioMed-1.0.zip file
3- cd PyBioMed-1.0
4-python setup.py install
Then I found out I need to install the rdkit package too. Based on this document I need to use conda while I have installed standalone python 3.6.8, so I installed miniconda then downgrade its python to 3.6.8 version and used the below command to install the Rdkit and successfully finished:
conda install -c conda-forge rdkit
Now, when I use this from PyBioMed.PyMolecule import moe, I get this ModuleNotFoundError: No module named 'rdkit'! May you help me how to declare, show or clarify the basic python that you can find Rdkit in conda's path?
Let me add the following points:
A- I am using the Windows 10.
B- I have added the below lines to the system path:
C:\Program Files\Python36\
C:\Program Files\Python36\Scripts\
C:\ProgramData\Miniconda3
C:\ProgramData\Miniconda3\Lib\site-packages
C:\ProgramData\Miniconda3\Library\mingw-w64\bin
C:\ProgramData\Miniconda3\Library\usr\bin
C:\ProgramData\Miniconda3\Library\bin
C:\ProgramData\Miniconda3\Scripts

Related

No module found error for a downloaded package (sksparse.cholmod) and how to download a package from the internet to conda

I need to use the sksparse.chomod package however my pycharm does not let me install it as it can't seem to find it.
I found the sksparse package on github and downloaded it but I do not know how to add a package downloaded from the internet into a conda environment. So, my first question would be can you download a package from github and add it to your conda environment, and how do you do this?
As I did not know how to do the above I instead saved the package within my project and thought I could simply import sksparse.cholmod. However, the line in my code that says import sksparse.cholmod as sks has no errors with it, so I assumed that meant this was ok, but when I try to run my file I get this error:
import sksparse.cholmod as sks
ModuleNotFoundError: No module named 'sksparse.cholmod'
If I have downloaded the package into my project why can't it be found, yet there are no errors when importing?
The cholmod file is a pyx file which I've been told should not be a problem.
Please could anyone help, I am reasonably new to python and I am looking for a straight forward solution that won't be time consuming.
It was an issue with windows, I was able to fix this using the instructions on this link
https://github.com/EmJay276/scikit-sparse
We must follow these steps precisely:
(This was tested with a Anaconda 3 installation and Python 3.7)
Install these requirements in order:
'''
conda install -c conda-forge numpy - tested with v1.19.1
conda install -c anaconda scipy - tested with v1.5.0
conda install -c conda-forge cython - tested with v0.29.21
conda install -c conda-forge suitesparse - tested with v5.4.0
'''
Download Microsoft Build Tools for C++ from https://visualstudio.microsoft.com/de/visual-cpp-build-tools/ (tested with 2019, should work with 2015 or newer)
Install Visual Studio Build Tools
Choose Workloads
Check "C++ Buildtools"
Keep standard settings
Run ''' pip install git+https://github.com/EmJay276/scikit-sparse '''
Test ''' from sksparse.cholmod import cholesky '''
Use all the versions stated for numpy etc, however with scipy I installed the latest version and it worked fine.

ModuleNotFoundError: No module named 'torch_scope'

Using the macOS terminal, I'm trying to run ./autoner_train.sh by following this guide on GitHub.
I have activated my Conda environment and check my PyTorch version
(pytorch_env) myname (master) AutoNER $ python -c "import torch; print(torch.__version__)"
1.3.1
After that, when running, I get the following error
ModuleNotFoundError: No module named 'torch_scope'
I don't know where's the problem. I have installed everything and I tried googling the problem, all I found is that I need PyTorch installed, which I already have.
I the documentation at the Dependencies section you can read:
Dependencies
This project is based on python>=3.6. The dependent package for this
project is listed as below:
numpy==1.13.1
tqdm
torch-scope>=0.5.0
pytorch==0.4.1
So you need to install torch-scope>=0.5.0 too:
pip install torch-scope

nrfutil - "ImportError: No module named main" on Nixos

I'm using the tool nrfutil which is implemented in Python. To be able to use it under NixOS I was using a default.nix file, that installed nrfutil into a venv. This worked for some time very well. (The last build on the build server using Nix within an alpine container could build the software I'm working on 11 days ago successfully.) When I do exactly the same things (i.e. restarting the CI server build without changes), the build fails now complaining about pip being incorrect:
$ nix-shell
New python executable in /home/matthias/source/tbconnect/bootloader/.venv/bin/python2.7
Not overwriting existing python script /home/matthias/source/tbconnect/bootloader/.venv/bin/python (you must use /home/matthias/source/tbconnect/bootloader/.venv/bin/python2.7)
Installing pip, wheel...
done.
Traceback (most recent call last):
File "/home/matthias/source/tbconnect/bootloader/.venv/bin/pip", line 6, in <module>
from pip._internal.main import main
ImportError: No module named main
To me it seems that the module main should exist:
$ ls -l .venv/lib/python2.7/site-packages/pip/_internal/main.py
-rw-r--r-- 1 matthias matthias 1359 10月 15 12:27 .venv/lib/python2.7/site-packages/pip/_internal/main.py
I'm not very much into the Python environment, so I don't know any further. Has somebody any pointer for me where to continue debugging? How is Python resolving modules? Why doesn't it find the module, that seems to be present to me?
This is my default.nix that I use to install pip:
with import <nixpkgs> {};
with pkgs.python27Packages;
stdenv.mkDerivation {
name = "impurePythonEnv";
buildInputs = [
automake
autoconf
gcc-arm-embedded-7
# these packages are required for virtualenv and pip to work:
#
python27Full
python27Packages.virtualenv
python27Packages.pip
# the following packages are related to the dependencies of your python
# project.
# In this particular example the python modules listed in the
# requirements.txt require the following packages to be installed locally
# in order to compile any binary extensions they may require.
#
taglib
openssl
git
stdenv
zlib ];
src = null;
shellHook = ''
# set SOURCE_DATE_EPOCH so that we can use python wheels
SOURCE_DATE_EPOCH=$(date +%s)
virtualenv --no-setuptools .venv
export PATH=$PWD/.venv/bin:$PATH
#pip install nrfutil
pip help
# the following is required to build micro_ecc_lib_nrf52.a in the SDK
export GNU_INSTALL_ROOT="${gcc-arm-embedded-7}/bin/"
unset CC
'';
}
I replaced pip install nrfutil with pip help to make sure the problem is not the package I try to install itself.
I'm still using python 2.7 as the nrfutil still is not fit for Python 3.
Anyway replacing python27 with python37 did not change the error I get when trying to start pip.)
NixOS version used locally is 19.09. Nix in the CI docker container is nixos/nix:latest which is the nix package manager on Alpine Linux.
Update:
Actually it works when I replace the call to pip install nrfutil with python2.7 -m pip install nrfutil. This actually confuses me even more. python2.7 is exactly the binary that is in the shebang of pip:
[nix-shell:~/source/tbconnect/bootloader]$ type python2.7
python2.7 is /home/matthias/source/tbconnect/bootloader/.venv/bin/python2.7
[nix-shell:~/source/tbconnect/bootloader]$ type pip
pip is /home/matthias/source/tbconnect/bootloader/.venv/bin/pip
[nix-shell:~/source/tbconnect/bootloader]$ head --lines 2 .venv/bin/pip
#!/home/matthias/source/tbconnect/bootloader/.venv/bin/python2.7
# -*- coding: utf-8 -*-
Update 2:
I found out that another way to fix the problem is to edit .venv/bin/pip. This script tried the following import:
from pip._internal.main import main
Which I think is the new module path starting with pip 19.3. But I still have pip 19.2. When I change this line to:
from pip._internal import main
Running pip by typing pip is working.
The thing is I have no idea why the pip script is trying to load the new module path while NixOS still has the old version of pip.
I also opened an issue for NixOS on GitHub: https://github.com/NixOS/nixpkgs/issues/71178
I got your shell derivation to work by dropping the Python27Packages.pip,
(nix-shell) 2d [azul:/tmp/lixo12333] $
>>> pip list
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Package Version
---------------- -------
behave 1.2.6
Click 7.0
crcmod 1.7
ecdsa 0.13.3
enum34 1.1.6
future 0.18.2
intelhex 2.2.1
ipaddress 1.0.23
libusb1 1.7.1
linecache2 1.0.0
nrfutil 5.2.0
parse 1.12.1
parse-type 0.5.2
pc-ble-driver-py 0.11.4
piccata 1.0.1
pip 19.3.1
protobuf 3.10.0
pyserial 3.4
pyspinel 1.0.0a3
PyYAML 4.2b4
setuptools 41.6.0
six 1.12.0
tqdm 4.37.0
traceback2 1.4.0
virtualenv 16.4.3
wheel 0.33.6
wrapt 1.11.2
(nix-shell) 2d [azul:/tmp/lixo12333] $
and my default.nix
with import <nixpkgs> {};
with pkgs.python27Packages;
stdenv.mkDerivation {
name = "impurePythonEnv";
buildInputs = [
automake
autoconf
gcc-arm-embedded-7
# these packages are required for virtualenv and pip to work:
#
python27Full
python27Packages.virtualenv
# the following packages are related to the dependencies of your python
# project.
# In this particular example the python modules listed in the
# requirements.txt require the following packages to be installed locally
# in order to compile any binary extensions they may require.
#
taglib
openssl
git
stdenv
zlib ];
src = null;
shellHook = ''
# set SOURCE_DATE_EPOCH so that we can use python wheels
SOURCE_DATE_EPOCH=$(date +%s)
virtualenv .venv
export PATH=$PWD/.venv/bin:$PATH
pip install nrfutil
#pip help
# the following is required to build micro_ecc_lib_nrf52.a in the SDK
export GNU_INSTALL_ROOT="${gcc-arm-embedded-7}/bin/"
unset CC
'';
}

Install Shapely on Windows 10

I need your help for installing Shapely. The project where I work is on PyCharm and I need to install Shapely to compile the project:
from shapely.geometry import Point, Polygon, MultiPolygon, asShape
I've tried to install it from the interpretor (Settings > Interpretor > +) but it says me that
"WindowsError: [Error 126] The specified module could not be found".
So I decided to install it from the command line. I think that I've Python 2.7 and Python 3.5 installed on my Windows 10 laptop (Python --version returns Python 2.7.12 and python3 --version returns Python 3.5.2). I executed the following line:
import pip._internal; print(pip._internal.pep425tags.get_supported())
[('cp27', 'cp27m', 'win_amd64'), ('cp27', 'none', 'win_amd64'),...]
When I run from my Download folder (where the .whl is)
pip install Shapely-1.6.4.post1-cp27-cp27m-win_amd64.whl
I have the following message error:
Shapely-1.6.4.post1-cp27-cp27m-win_amd64.whl is not a supported wheel on this platform.
I have Python 2.7 (cp27) and my pip supports win_amd64. I don't really know what I can do now.
Try using conda install shapely, that helps avoid breaking your packages as well.

Unable to use azure SDK in Python

I did this:
sudo pip install azure azure-storage azure-servicebus azure-mgmt azure-servicemanagement-legacy
from azure import *
Traceback (most recent call last): File "", line 1, in
ImportError: No module named azure
from azure.storage import BlobService
Traceback (most recent call last): File "", line 1, in
ImportError: No module named azure.storage
Python package installed thru cmd sudo pip install exists at the paths /usr/lib/python2.7, /usr/local/python2.7, etc and their sub-folder dist-packages.
You can code import sys and print sys.path in the Python Interpreter to show the completed path list for current python environment.
Iif you installed successfully some packages like azure & azure-storage, you can find these files relate to the package in the python library paths.
However, you got the error in Import Error: No module named <package-name> when you run the code import <package-name> or from <package-name> import <class or object name>. There are two scenes that would be cause the issue normally.
Package not installed successfully.
The library path included package that not exists in Python system environment path sys.path in python or PYTHONHOME in environment variables.
So I think you can try to solve the issue thru three ways below.
Dynamically add the package path into sys.path thru the method sys.path.append('<package path>') in python code.
Check the environment variable PYTHONHOME whether or not set up. If set up PYTHONHOME, python will add package path based on PYTHONHOME into sys.path.
If your python environment encounter some unknown fault that is unrecoverable, you can try to reinstall Python thru commands sudo apt-get remove python python-pip, sudo apt-get update, sudo apt-get install python python-pip on Ubuntu. It's a simple way.
BlobService belongs to azure.storage.blob rather than the azure.storage
it should rather be
from azure.storage.blob import BlobService
Link - https://azure.microsoft.com/en-us/documentation/articles/storage-python-how-to-use-blob-storage/
If it still doesn't work for you, you might would like to use virtualEnv and do the pip install again while in virtualenv
http://docs.python-guide.org/en/latest/dev/virtualenvs/
I had very similar issue. There was a lot of confusion between python2 and python3 package versions as there was no virtual env used and I also had to ungrade pip to 18.
But anyway, this is is how I resolved the part in question.
Locate where the package was installed:
pip show azure
The output will show the location of the package in the Location section:
Name: azure
Version: 4.0.0
Summary: Microsoft Azure Client Libraries for Python
Home-page: https://github.com/Azure/azure-sdk-for-python
Author: Microsoft Corporation
Author-email: azpysdkhelp#microsoft.com
License: MIT License
Location: /usr/local/lib/python3.6/dist-packages
Requires: azure-servicefabric, azure-cosmosdb-table, azure-datalake-store, azure-loganalytics, azure-eventgrid, azure-servicemanagement-legacy, azure-servicebus, azure-graphrbac, azure-storage-blob, azure-mgmt, azure-storage-file, azure-batch, azure-applicationinsights, azure-keyvault, azure-storage-queue
Required-by:
If you do:
python -c "import sys;print(sys.path)"
You will see a list of pip package locations:
['/app', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages']
At the begining of my python file I added:
sys.path.insert( 0, '/usr/local/lib/python3.6/dist-packages' )
This will make sure this package location will be checked in the first place.
UPDATE
Thinking about it in the morning, things opened from a new perspective for me. I saw, that I had #!/usr/bin/python at the beginning of my python file, which says to use the wrong interpreter and look for pip packages in the wrong place.
azure metapackage is deprecated
and azure-storage is not being maintained anymore
Please use azure-storage-blob >= 12.0
pip install azure-storage-blob
from azure.storage.blob import BlobServiceClient
PS: I write SDKs for azure

Categories