Installing nltk in anaconda (super computer) - python

I am using a super computer to work on my project(data science) which needs big RAM.
it has big dataset that even using colab with the subscription didn’t work.
I want to run a python code nut when I run it, it sys nltk package is missing.
itried to install it but this shows up.
(my_env) [ayalmalki#klogin2 ~]$ conda install -c anaconda nltk
Solving environment: failed
CondaValueError: Malformed version string '~': invalid character(s).
after talking to the support team of the super computer they said the following:
"we only support python 3.6.8
you should use nltlk 3.6.4"
so I did downgrade python Version and tried to install nltk but it shows the same error
(my_env) [ayalmalki#klogin2 ~]$ conda install -c anaconda nltk=3.6.4
Solving environment: failed
CondaValueError: Malformed version string '~': invalid character(s).
is there a way to download nltk manually or another way to run my code other than super computer or something i need help

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.

Windows 10 - Anaconda 2020.02 - GTK installation fails, gdk-pixbuf

Using the solution from:
Ubuntu - Anaconda 2020.02 - Namespace Gtk not available
and trying this on a Windows 10 system (again, Anaconda 2020.02) a different problem appeared.
An error box pops up, titled 'gdk-pixbuf-query-loaders.exe - Entry Point Not Found', with the text: The procedure entry point libiconv_set_relocation_prefix could not be located in the dynamic link library C:\Users\Me\Anaconda3\Library\bin\glib-2.0.0.dll
The text on the console shows up as 'An error occurred while installing package 'conda-forge::gdk-pixbuf-2.38.2-h67ea0bb_3'
Not too sure what is going on, again. It would seem that Anaconda thinks these are OK:
https://anaconda.org/search?q=gtk3
https://anaconda.org/search?q=gdk-pixbuf
Installation of gdk-pixbuf seems to be the sticking point, as that fails to install.
Trying to install with 'conda install -c conda-forge gtk3=3.24.14=ZZZZZZZZ' and ZZZZZZZZ are the two different builds yields the same error.
Additional information:
A clean install of Anaconda, with no updates, only:
conda install -c conda-forge gtk3
... still yields problems (lots and lots of conflicts), and the original answer (to install glib) did not consistently solve the problem.

Package already installed but getting error like No module name "plspm" in Python?

I have started getting this error for a "plspm" module in python which is part of R library after I 'conda install plspm' on my windows 10 OS. Installation has been done properly but i could not able to import plspm in python getting "No module" error. Please anyone help me to resolve.Thanks.
version of r-plspm is -0.4.9
needed packages already installed(scipy,skit-learn,pandas,numpy,statsmodule).
command used to install:
conda install -c conda-forge r-plspm
Screen shot of installed plspm:
Error:

error when downloading the gensim package in python

I have been trying to install the gensim package in python using pip, using the pip.main(['install','gensim']). It works and starts downloading, but then I get the following error:
THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
gensim from https://files.pythonhosted.org/packages/82/f2/c2f2c87ed72483fce010fbfea1a3adbd168c0f0dafc878cbfb5a76381b03/gensim-3.4.0-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl#sha256=7bafe3f2fd49738942ef04396cb1e50a38283fe02203e5d4c66588daa01fb87c:
Expected sha256 7bafe3f2fd49738942ef04396cb1e50a38283fe02203e5d4c66588daa01fb87c
Got 728e9e79db209cfb0699c815c30a6169cefa61f46ef3471937100e4173fdbb3d
Any help would be appreciated
It seems like the package pip is trying to download and install is being modified in transit. You should be able to download, verify, and install the package yourself.
Download the package:
$ curl -O https://files.pythonhosted.org/packages/82/f2/c2f2c87ed72483fce010fbfea1a3adbd168c0f0dafc878cbfb5a76381b03/gensim-3.4.0-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
Calculate the SHA256 sum to ensure the package has not been modifed:
$ openssl sha256 gensim-3.4.0-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
The output should be 7bafe3f2fd49738942ef04396cb1e50a38283fe02203e5d4c66588daa01fb87c (according to https://pypi.org/project/gensim/#files)
Install the package:
$ pip install gensim-3.4.0-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl
I didn't solve the problem but I found a way to work around this challenge. I started using anaconda directly. I used the navigator to install gensim in my environments, then I used the spyder command prompt to run my codes.
These links are useful:
https://docs.anaconda.com/anaconda/navigator/
https://docs.anaconda.com/anaconda/install/
https://www.anaconda.com/download/#macos

How do I pip install pattern packages in python 3.5?

How do I pip install pattern packages in python 3.5?
While in CMD:
pip install pattern
syntaxerror: missing parentheses in call to 'print'
Shows error:
messageCommand "python setup.py egg_info" failed with error
code 1 in temp\pip-build-3uegov4d\pattern
seaborn and tweepy were all successful.
How can I solve this problem?
pip install pattern3 - Python 3.x
pip install pattern - Python 2.7.x
As of writing, Python 3.6 support is still not merged with master. However, it is available in the python3 branch.
To install via pip:
pip install https://github.com/clips/pattern/archive/python3.zip
Note that ThReSholD's answer for Python 3 (pattern3) is for a:
deprecated pattern3 repository which contains a completely different code base that is not maintained anymore
It looks like from the documentation that, for python 3, pattern is only supported in 3.6 and up. https://github.com/clips/pattern#installation
This worked for me to get pattern.en working in python 3.6:
git clone -b development https://github.com/clips/pattern
cd pattern
sudo python3.6 setup.py install
https://github.com/clips/pattern/issues/62
I had some SSL errors during installation on my mac (10.11.6) that were fixed by running this code in python (3.6):
import nltk
import ssl
try:
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
pass
else:
ssl._create_default_https_context = _create_unverified_https_context
nltk.download('wordnet_ic')
apparently there's a better way to deal with ssl stuff like this fwiw:
https://stackoverflow.com/a/41351871/8870055
sanity check:
user#USDR00253 ~> python3.6
Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> from pattern.en import conjugate, lemma, lexeme, parse
>>>
>>> print(parse('ridden', relations=True, lemmata=True))
ridden/VBN/B-VP/O/O/ride
>>>
pattern.en finally running in python 3!
The short answer at the moment is - you can't. They haven't quite finished the port to python3 yet.
There is alleged compatibility in the development branch but the recommended manual setup didn't work for me (in virtualenv) - it fails in a different way.
https://github.com/clips/pattern/tree/development
The porting issue thread is here, spanning 2013 to yesterday:
https://github.com/clips/pattern/issues/62
The official A contributing port repo is here, but it's not finished yet (the readme says there is no Python3 support).
https://github.com/pattern3/pattern
So you could try pip install pattern3 which does install it - but it has a different package name, so you would have to modify any references to it. For me this is "impossible" as it's required by other 3rd party packages like GenSim.
UPDATE
I did get it working in the end in Python3 with Gensim, by manually installing it from the development branch as suggested and fixing up a few problems both during install and execution. (I removed the mysql-client dependency as the installer isn't working on Mac. I manually downloaded the certs for the NTLK wordnet corpus, to fix an SSL error in the setup. I also fixed a couple of scripts which were erroring, e.g. an empty 'try' clause in tree.py). It has a huge set of dependencies!
After reading more on the port activity, it seems they're almost finished and should release in a few months (perhaps early 2018). Furthermore the pattern3 repository is more of a "friend" than the official Python3 fork. They have already pulled the changes from this contributor into the main repo and they are preparing to get it released.
Therefore it should become available on pip in the main pattern package (not the pattern3 one which I presume will be removed), and there should be no package name-change problems.
For Mac OS:
brew install mysql
export PATH=$PATH:/usr/local/mysql/bin
pip3 install mysql-connector
pip3 install https://github.com/clips/pattern/archive/python3.zip
In the upgrade from python 2.x to 3.x, the print statement was made into a function call rather than a keyword. What used to be the line print "Hello world!" is now the line print("Hello world!"). So now all code written for 2.x that prints to the console does not work in version 3.x, as the compiler hits a runtime error on the print statement.
There are really only two fixes to this problem: Use version 2.x instead, or find a library built for version 3.x.
Additionally, I was facing :
"BadZipFile: File is not a zip file" error while importing from pattern.
This is because sentiwordnet which is out of date in nltk. So comment it in :
C:\Anaconda3\Lib\site-packages\Pattern-2.6-py3.5.egg\pattern\text\en\wordnet\_init.py
Make sure the necessary corpora are downloaded to the local drive
for token in ("wordnet", "wordnet_ic"): , "sentiwordnet"
try:
nltk.data.find("corpora/" + token)
Using Windows Subsystem for Linux, I made pattern to work using conda from (miniconda) in
Python 3.6:
conda create -n test -c conda-forge python=3.7 pattern
conda activate test
works without issues
Python 3.7:
conda create -n test -c conda-forge python=3.7 pattern
conda activate test
I discovered that there is a bug with StopInteration due to PEP-479, and replacing raise StopIteration with return in pattern\text\__init__.py fixes it.
To find the location if the file, I executed
cd $(python -c "from distutils.sysconfig import get_python_lib;print(get_python_lib())")
nano pattern/text/__init__.py
Line 605, just above class Lexicon(lazydict): ... replace raise StopIteration with return.
And all is working fine.

Categories