YouCompleteMe completed failed - youcompleteme

➜ YouCompleteMe git:(master) ./install.py --clang-completer
Searching Python 3.7 libraries...
ERROR: Python headers are missing in /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/Headers.
I used brew to install python and have not downloaded Xcode

Ended here after having the same problem. The problem in my case was that the python version that was being used was not the correct one. So even after executing:
brew reinstall python3
I was getting the error.
What finally fixed the issue was to explicitly state which python interpreter to use:
/usr/local/bin/python3.9 install.py --all

In my case, I needed to close iTerm and re-open it. So if reinstalling python3 didn't work, try this or alternatively:
source ~/.zshrc

I encountered this problem because of multiple python installations on my machine, one is anaconda python, another is standard python.
I will introduce every step I've done to deal with it.
At first, I used anaconda Python to build YCM. The YCM Server cannot be started and I got the cause from this issue. But when I tried to install YCM using standard Python with the command:
$ /usr/bin/python3 install.py --go-completer --clang-completer --go-completer
The result of execution is an error message as follows:
ERROR: Python headers are missing in /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers.
The installation failed; please see above for the actual error. In order to get more information, please re-run the command, adding the --verbose flag. If you think this is a bug and you raise an issue, you MUST include the *full verbose* output.
For example, run:/Library/Developer/CommandLineTools/usr/bin/python3 /Users/jianxue/.vim/bundle/YouCompleteMe/third_party/ycmd/build.py --go-completer --clang-completer --go-completer --verbose
I was so confused for a long time. And at last, I tried to deactivate the anaconda python, and the standard Python was the default one now.
python3 install.py --go-completer --clang-completer --go-completer
Succeed! I guess anaconda overrides the python configurations. Although I used the standard python, the c header for python still couldn't be found by OS.

Related

ERROR when trying to build chromium on my own computer

Right now, I am tring to build Chromium on my own computer under instructions at https://chromium.googlesource.com/chromium/src/+/master/docs/linux/build_instructions.md#Build-Chromium
At first, it went smoothly. However when I run
$ autoninja -C out/Default chrome
when I run this to start build. It started. And then an error occured and the build process is terminated.
The error is
NameError: name 'unicode' is not defined" and I know it is a common error associated with the difference between python2 and python3.
However, I don't know how to let the ninja use only python2 and avoid this bug.
If you can help me, I will really appreciate it.
I recently ran into this issue when attempting to home build the Brave browser, which is chromium based. It appears that chromium build is based on python2, which is fine, but uses plain calls to "python" in the scripts. Obviously, essentially all modern distros put a symlink to python3 at python in the PATH (generally /usr/bin/python -> /usr/bin/python3). I still retain hope that there is a way to configure the "python path" in the build system, but have not found it and I am not too familiar with ninja.
The first way I "solved" this, and managed a successful build is one I consider a hack and do not recommend as a solution without the stipulation that it leaves your system broken so don't run too many other things. This is to manually temporarily update the symlink. Assuming you have both /usr/bin/python2 and /usr/bin/python3 on your system, remove the symlink at /usr/bin/python and replace it with one to python2:
sudo rm /usr/bin python
sudo ln -s /usr/bin/python2 /usr/bin/python
You can then run the chromium build, and reverse the above change when completed. Note that anything on your system that requires python3 to be at the symlink python cannot be run during this time. I have successfully used this technique to build Brave (and then reverse the change after the build completed).
I can offer you some other options too. One is to set up pyenv. If you search for that, you will find it is a suite that allows you to manage multiple python versions and have different directories use different ones. I researched this, and assume it can work, but have not done it myself.
The next option, which I am currently undertaking right now, is basically a manual watered down version of what pyenv does. I will let you know how it goes. The essence is to add a symlink in the path that will redirect python calls for that instance of the shell (and all subshells it creates). Assuming you are in the source directly at the obvious path:
mkdir .shims
ln -s /usr/bin/python2 .shims/python
export PATH=/home/yourname/src/Chromium/.shims:$PATH
python --version
This should print out whatever version of python2 you have rather than python. Anytime you come back to work here, you have to export the new PATH again. The rest of your system is unaffected, and still finds python3 at python. You can open up a new terminal and type python --version to verify that.
I have Chromium building on Fedora 33. Somewhere in the Chromium build, /usr/bin/python is getting run explicitly. On Fedora, that means Python 3.
If you change /usr/bin/python to point to python2.7, I bet your build will work.
Creating aliases for "python" won't work.
If this works, consider using the alternatives command to easily change /usr/bin/python:
alternatives command for /usr/bin/python

Installing emscripten on Mac OS X

I try to install Emscripten following their instructions on the website, but I ran into some weird errors:
When I do ls -l in the command line in the emscripten folder, the command line returns 0, but when I look it up with finder I can find the folder 1.35.0. So I cd 1.35.0
There I try to run ./emcc -v, but I get this error: env: python2: No such file or directory
Does anyone know what I am doing wrong ? Thanks for help.
I'm not sure about your first question, but Emscripten does require a version of Python 2.x called "python2" to be available. It doesn't matter than the Mac OS built-in version is Python 2.7.
Since the OS no longer allows sym-links to files in /usr/bin, I copied mine to /usr/local/bin and just called it python2 there. I'm sure there is a simpler solution, but this works.

Pyomo can't locate GLPK solver

I'm trying to use the GLPK solver with Pyomo. I have a working model that's been tested, but keep getting an error saying GLPK can't be found.
WARNING: Could not locate the 'glpsol' executable, which is required for solver 'glpk'
I've installed glpk sucessfully. I also added the directory to my path variable so the executed can be called globally. I tested this with glpsol --help from my command line, and see the help info printed.
The below thread says it should be working, but alas, it is not.
How do you install glpk-solver along with pyomo in Winpython
Any ideas?
This answer is late but I want to share the solution that worked for me.
solvername='glpk'
solverpath_folder='C:\\glpk\\w64' #does not need to be directly on c drive
solverpath_exe='C:\\glpk\\w64\\glpsol' #does not need to be directly on c drive
I used to do this:
sys.path.append(solverpath_folder)
solver=SolverFactory(solvername)
This works for the cbc solver in coin-or but it does not work for glpk. Then I tried something different:
solver=SolverFactory(solvername,executable=solverpath_exe)
This worked for both cbc and glpk. No idea why this works (I really didn't do anything else).
Version: Python 2.7 or Python 3.7 (tested both), glpk 4.65
You can install glpk solver using this command -
brew install glpk
Installing the glpk package worked for me. As I use Anaconda:
conda install -c conda-forge glpk
This was after already including the 'glpsol' exectuable's folder path in my PATH variables.
So it looks like the set path variable is not handled by your Python installation.
A normal Python installation is set up for a seperated "PYTHONPATH" environment variable to look up additional modules.
There is also the option to make an entry in the windows registry or (like you already mentioned) move the files to the Python home directory, which is recognized relative to your installation directory if "PYTHONHOME" is not set.
More information in the Python Documentary under 3.3.3.
https://docs.python.org/2/using/windows.html#finding-modules
I was having the same issue. I don't know if this is a solution but it definitely got the solver working.
After downloading the Windows installation. I copied all the files in the w64 folder and pasted them directly into my Python working directory.
After that my python code could locate the solver.
NOTE: this was for Python 3.4.3.4, Windows 8.1 64 bit
Reading the source code here suggests you try:
from pyutilib.services import register_executable, registered_executable
register_executable(name='glpsol')
maybe will it give a clue
I had the same issue on Windows 10 and it was down to glpk being installed in a different conda environment. Full steps for installing pyomo and glpk below.
Test the installation by running 'Repeated Solves' example from https://pyomo.readthedocs.io/en/latest/working_models.html
Instructions (run at an anaconda prompt)
conda create --name myenv
conda activate myenv
conda install -c conda-forge pyomo
conda install -c conda-forge pyomo.extras
conda install -c conda-forge glpk
Run spyder from myenv so that if finds everything
spyder activate myenv
Here is the relevant part where pyomo 6.2 searches for the glpsol executable
https://github.com/Pyomo/pyomo/blob/568c6595a56570c6ea69c3ae3198b73b9f473abd/pyomo/common/fileutils.py#L288
def _path():
return (os.environ.get('PATH','') or os.defpath).split(os.pathsep)
There are two options to solve the PATH problem:
Putting the executable in an available folder in PATH (recommended practice). The glpsol executable must be in one of the folders present in the PATH system environment variable. Use in your code print(os.environ['PATH']) to see the available folders and put it there.
Adding the folder to PATH at runtime. You can add it to the system PATH statically or use code to add it dynamically (only while your script is running):
GLPK_FOLDER_PATH = "path/to/glpk"
os.environ["PATH"] += os.pathsep + str(GLPK_FOLDER_PATH)
In my case, my Python project has a virtual environment .venv, and I have an installation process that pastes the files essential to the glpsol executable when I install the project inside the .venv/Scripts folder. Because that folder is added automatically to the system PATH when Python is called from the virtual environment, libraries like Pyomo can find it. And I don't have to remember to add the folder to PATH at runtime whenever I want to use Pyomo.
For anyone that has the same issue, I found a workaround (not a solution!). I copied all the glpk files into my C:/Python27 directory, and (Surprise!) Python can now find them.
I'll hold out for a real solution before accepting this one.

The tools required to build C++ code for R were not found

OS: Ubuntu 14.04
g++: g++ (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
R version: 3.2.0 (2015-04-16) -- "Full of Ingredients"
Rcpp: 0.11.6
Today I apt-get dist-upgrade my system, and the g++ was also been upgraded.
Then when I am trying to use "Rcpp" package in R, the code is the simplest test code >>evalCpp("1+1") . An error as follows occurred:
Error in frameTypes(env) : not a proper evaluation environment
Calls: ::: ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
Error in sourceCpp(code = code, env = env, rebuild = rebuild,showOutput = showOutput, :
Error 1 occurred building shared library.
WARNING: The tools required to build C++ code for R were not found.
Please install GNU development tools including a C++ compiler.
I have did google for it. The following links are all about Mac OSX:
Error when with Xcode 5.0 and Rcpp (Command Line Tools ARE installed)
g++ errors when trying to compile c++11 with Rcpp
From the answers and comments, I can not tell what is the real problem.
Appreciate your help!
UPDATE: I finally solved this problem by reinstalling all the R related deb packages. And one thing we should keep in mind is that I also did what #Dirk suggested first apt-get build-dep r-base-dev. I can not confirm which one is the key step.
You need
sudo apt-get build-dep r-base
to install the all the build dependencies for R itself.
But we even built an explicitly helper package r-base-dev so in most cases (and in your use case of Rcpp) you just need
sudo apt-get install r-base-dev
There is something wrong/missing in your system configuration. First of all, I doubt that you are really running Ubuntu 14.04 (after the dist-upgrade) because the the other versions that you listed wouldn't be available (unless you have pulled them in from a non-default repository). You might also consider running a full-upgrade to try to straighten out your configuration.
You might gain some insights by running with showOutput=1...
library(Rcpp)
evalCpp("1+1",showOutput=1,rebuild=1)
...but actually, it looks like the problem is related specifically to a parameter called env (Error in frameTypes(env) : not a proper evaluation environment) which is likely evaluated prior-to attempting to compile.
For what it is worth, I was able to run this without r-base-dev installed, but maybe installing r-base-dev will pull in the correct, and updated, versions of what you need. I would be inclined to just reinstall all R-related packages.

How to use -pip- to install packages that can work with Anaconda?

I am trying to install some additional packages that do not come with Anaconda. All of these packages can be installed using pip install PackageName. However, when I type this command at the Anaconda Command Prompt, I get the following error:
Fatal error in launcher: Unable to create process using '"C:\Python27\python.exe
" "C:\python27\scripts\pip.exe" install MechanicalSoup'
I also tried to run the command from the python interpreter after import pip but that also did not work (I got a SyntaxError: invalid syntax).
I am a noob and understand that this might be a very basic question so thanks for your help in advance!
PS: I am using Windows 7, 64 bit, conda version: 3.7.1 and python version: 2.7.6.
When installing anaconda, you are asked if you want to include the installed python to your system PATH variable. Make sure you have it in your PATH. If everything is set up correct, you can run pip from your regular command prompt aswell.
Using #heinzchr's and #mmann's suggestions I was able to piece together the problem. I already had a version of Python 2.7 saved at C:\Python27 and I had to remove this from the Path (My Computer's properties> Advanced system settings> System variables> Path). I can now use pip install from the command line.
There is a way around the use of pip
From the anaconda terminal window you can run:
conda install PackageName
Because MechanicalSoup isn't in one of anaconda's package channels you will have to do a bit of editing
See instructions near the bottom on their blog
For those looking for Python packages not added to current channels in anaconda, try https://conda-forge.org/ For example, if you want to install MechanicalSoup you'll find it at https://anaconda.org/conda-forge/mechanicalsoup and use the -c option to tell conda the channel to use:
conda install -c conda-forge mechanicalsoup