Using Microsoft Windows 7.0 OS and wanted to be able to call pip for ease of installing Python modules. I first installed distribute.
After running the module:
pip install -U scikit-learn
I realized that I need to set the BLAS environment variable. I do not fully understand what this entails, i.e. what should it be set to? set BLAS="something"
(Note: I also skipped this and tried: easy_install -U scikit-learn, which seemed to work fine. But when I attempt to import the module in iPython it doesn't recognize it, it gives "invalid syntax" pointing to "-").
Appreciate your thoughts.
Related
I want to import MeCab and use it, but that error comes out repeatedly.
MeCab-python is well installed.
I've tried Brew install and so on, and it's still the same.
I'd appreciate it if you could help me if you knew the solution.
Hmm. On a fresh macOS 13.1 Ventura, I just did this:
Installed miniconda https://docs.conda.io/en/latest/miniconda.html#latest-miniconda-installer-links
conda create -n mecab-tutorial and answering questions
conda activate mecab-tutorial
conda install python ipython and saying 'yes'
python -m pip install mecab-python3 unidic-lite
Then I was able to run this script:
import MeCab
wakati = MeCab.Tagger("-Owakati")
wakati.parse("pythonが大好きです").split()
# ['python', 'が', '大好き', 'です']
Looking at the path in the error in the screenshot, it looks like you installed a global Python in /Library which I don't want to try because I very much prefer to keep my Python environments local, hence using Conda above to create a custom environment to install MeCab packages in to ensure no cross-contamination later.
There's no guarantee that this will work if you try it since the error you're seeing seems to be a compiler issue (Python is finding MeCab, just having trouble calling a C++ function inside the binary), but if possible, can you try the Conda approach above?
There are a lot of other questions like mine but they're quite outdated so I think a new updated guide would be helpful for everyone trying to install rpy2 in Python.
In my case, I'm trying to work with the package pymer4 but i couldn't manage to correctly import it.
I found out that the error lies in rpy2.robjects so I decided to follow this answer to create a clean environment
Steps
I created a new conda environment
conda create -n rpy2_env r-essentials<4.2 r-base<4.2 python=3.7
I set the version to <4.2 because I read online this problem can be caused by a wrong r version. Anyway neither 4.2 nor 4.1 worked for me.
I installed the pymer4 package (and its dependecies, including rpy2)
conda install -c ejolly -c conda-forge pymer4
I downgraded rpy2 to 3.4.5 (see related question below, I also tried without downgrading)
conda install rpy2=3.4.5
When i try to import pymer4 or rpy2.robjects the following error shows up
R[write to console]: Error in gettext(fmt, domain = domain, trim = trim) :
3 arguments passed to .Internal(gettext) which requires 2
In the terminal the logs showed no error during download and installation.
If you need more info about my system or anything else, comment and I will update the question.
I am really stuck at this point, I think i tried everything I could. I would really appreciate if someone could enlighten me.
Similar Questions
Import rpy2 : unable to determine R library path
Rpy2 can't find my R libraries on install
R[write to console]: Error in gettext(fmt, domain = domain, trim = trim) : 3 arguments passed to .Internal(gettext) which requires 2
I think I found the solution.
The problem is with conda and rpy2, apparently rpy2 installed with conda is outdated.
You can install correctly rpy2 on a new environment (venv or conda env) using pip.
I did it and so far it's working perfectly.
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.
I'm having trouble installing packages and using them in Pycharm. I've followed various threads (I'm new to Macs and seem to have tried everything) now I'm stuck.
In this case, I want to use the package xgboost.
I have brew installed, after launching a terminal using Rosetta:
%brew install xgboost
Warning: xgboost 1.3.3 is already installed and up-to-date.
It appears installed OK here:
/opt/homebrew/Cellar/xgboost
I also have Python installed here:
/opt/homebrew/Cellar/python#3.9
But no matter how I configure an Interpreter in Pycharm, I can't seem to get the package recognised.
Where have I gone wrong?
I am very unsure exactly how, but I've got this working.
Following: https://abbasegbeyemi.me/blog/homebrew-python-apple-m1
I changed the order of elements in my path:
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin
then a new interpreter in Pycharm using:
usr/local/Cellar/Python#3.9/3.9.2_2/bin/python3.9
Now I can install packages just using pip in pycharm and it works.
This has been 6 hours of pain - warning to anyone who isn't well versed in macs, setting up an M1 for python dev was a complete nightmare for me.
Docs: https://xgboost.readthedocs.io/en/latest/build.html
Pre-built binary wheel for Python
If you are planning to use Python, consider installing XGBoost from a pre-built binary wheel, available from Python Package Index (PyPI). You may download and install it by running
# Ensure that you are downloading one of the following:
# * xgboost-{version}-py2.py3-none-manylinux1_x86_64.whl
# * xgboost-{version}-py2.py3-none-win_amd64.whl
pip3 install xgboost
I'm trying to install numpy under Python 3.3.0 running Mac OS 10.7.5 (Lion) and using the compilers that come with Xcode 4.5.1. I installed Python 3 and gfortran using homebrew without any hiccups, but pip3 install numpy fails. Looking at other suggestions online, I tried setting Clang as the C compiler using:
export CC=clang
export CXX=clang
export FFLAGS=-ff2c
but received the same error. The final line reports ValueError: underlying buffer has been detached, and I posted the full output.
So, instead I tried building directly from source using the instructions from SciPy.org. This appears to succeed; the build and install processes run to completion, although they are not shy about reporting warnings. The full log is again available as a Gist. I can then run numpy.test('full') from Python 3, and although there are some warnings about unclosed files that I don't understand, it reports that all tests pass.
Does anyone know why pip fails to build NumPy when I can apparently do it manually without a problem?
It looks like numpy now provides wheels on pypi, which should install correctly without needing to compile anything locally on your machine when using pip.