install caffe on mac " Error: invalid option: --with-python" - python

when I install the caffe on mac according to :
Remaining dependencies, with / without Python
# with Python pycaffe needs dependencies built from source
brew install --build-from-source --with-python -vd protobuf
brew install --build-from-source -vd boost boost-python
# without Python the usual installation suffices
brew install protobuf boost
I paste the second one to the terminal, and result is:
Error: invalid option: --with-python
I can not find any similar problem, can some help me with that?

Options have been removed from Homebrew core formulas and only exist in taps now. See this GitHub issue. Building with python has been made the default behavior for protobuf.
See the formula, lines 49-51.
chdir "python" do
system "python3", *Language::Python.setup_install_args(libexec),
"--cpp_implementation"
So it should be fine to run
brew install --build-from-source -vd protobuf

Related

Error in installing OpenCV with python (MAC OSX) and PyCharm IDE

I want to install the OpenCV to then include it in PyCharm on my Mac, and
I have started with the terminal following this guideline: click here
the problem is when I follow the third step and write this code:
$ brew install opencv3 --with-contrib --with-python3
this error has shown:
Error: invalid option: --with-contrib
Of course I have installed also the PyCharm IDE for python and the latest verson of python (3.7) to be knowledged
please if you can help me I will appreciate that
This problem was solved! thank you
According to the formula, opencv3 no longer requires these flags.
CMake flags
-DOPENCV_ENABLE_NONFREE=ON
-DOPENCV_EXTRA_MODULES_PATH=#{buildpath}/opencv_contrib/modules
enable support for contrib modules.
-DBUILD_opencv_python2=ON
-DBUILD_opencv_python3=ON
-DPYTHON2_EXECUTABLE=#{which "python"}
-DPYTHON2_LIBRARY=#{py2_lib}/libpython2.7.dylib
-DPYTHON2_INCLUDE_DIR=#{py2_prefix}/include/python2.7
-DPYTHON3_EXECUTABLE=#{which "python3"}
-DPYTHON3_LIBRARY=#{py3_config}/libpython#{py3_version}.dylib
-DPYTHON3_INCLUDE_DIR=#{py3_include}
provide support for Python3 as well as Python2.
Just run
brew install opencv3

Python2 version set to Python3 in version check

So I was trying to install OpenCV in on the MacOS following this tutorial: https://www.pyimagesearch.com/2016/12/19/install-opencv-3-on-macos-with-homebrew-the-easy-way/
In step 3 the versions of python should be python 2.x checked with python --version and python 3.y checked with python3 --version. However on both commands I am getting Python 3.6.4. How can I fix this? I have tried to install python 2 again with brew install python#2 and the output is python#2 2.7.14_1 is already installed. which python shows /usr/local/bin/python whereas which python3 shows /usr/local/bin/python3.
If you installed Python 2 and Python 3 with Homebrew, then the Python 2 binary is named python2, but will not be linked into /usr/local unless you use brew link with the --force flag.
See brew info python#2:
$ brew info python#2 | grep Caveats -A 4
==> Caveats
This formula installs a python2 executable to /usr/local/opt/python#2/bin
If you wish to have this formula's python executable in your PATH then add
the following to ~/.bash_profile:
export PATH="/usr/local/opt/python#2/libexec/bin:$PATH"
$ brew info python#2 | grep 'not symlinked' -A 2
This formula is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
You can run
/usr/local/opt/python\#2/bin/python2
if you need to run it directly, or you can force homebrew to link it in anyway with:
brew link --force python#2
at which point /usr/local/bin/python2 will be added.
The tutorial is rather outdated; how homebrew handles Python has changed. Just use python2 wherever it uses python.
To further address the tutorial:
brew linkapps is deprecated
the homebrew/science tap is deprecated, the formulas in that tap have been migrated, opencv3 can be installed without additional taps.
the current version of the opencv3 natively supports both Python 2 and 3, no configuration switches required
the formula directly depends on the Python 2 and 3 formulae, installing opencv3 will automatically install Python.
So just run brew install opencv3, follow any additional instructions that command prints (could be none).
Do make sure you update Homebrew as there were some dependencies missing (see my bug report with Homebrew). If you don't, you'll have to run brew install hdf5 tesseract to install dependencies that should have been optional.
The tutorial is almost entirely obsolete now.

Attempted install of Python 3 via homebrew fails on Mac OS X Sierra

I'm trying to install Python 3 alongside 2.7 with Homebrew but am receiving an error message I can't find a resolution to.
When attempting brew update && brew install python3 I get the following error:
Error: python 2.7.12_2 is already installed
To upgrade to 3.6.4_3, run `brew upgrade python`
I want to leave the python 2.7 installation alone so I can have both Python 2 & 3 accessible on my machine so I'm nervous that upgrading will overwrite the current 2.7 installation.
I figure I can still perform a clean side-by-side install with the package from python.org, but I want to know why I'm getting this homebrew error
brew doctor shows the following Warnings containing python
Warning: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.
Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:
/Library/Frameworks/Python.framework/Versions/2.7/bin/python-config
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2-config
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
Warning: Python is installed at /Library/Frameworks/Python.framework
Homebrew only supports building against the System-provided Python or a
brewed Python. In particular, Pythons installed to /Library can interfere
with other software installs.
Warning: Some installed formulae are missing dependencies.
You should `brew install` the missing dependencies:
brew install python#2
To be honest, and what I also have on my own system, is Python 3 as the default and Python 2 available if I need it. With homebrew, you can just update your default as it wants you to do with the upgrade. That means when you run python, Python 3 will run as the default.
For Python 2, install brew install python#2. When you want to run Python 2, just run python2 in the terminal and you'll have it.
Python install will run once you fix the broken links by running brew link, and the missing link component.
These usually don't need SUDO, they will link then and run brew doctor once they have all been linked.

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available

I am using Python 3.6. When I try to install "modules" using pip3, I face this issue:
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available
For Windows 10
if you want use pip in normal cmd, not only in Anaconda prompt. you need add 3 environment paths.
like the followings:
D:\Anaconda3
D:\Anaconda3\Scripts
D:\Anaconda3\Library\bin
most people only add D:\Anaconda3\Scripts
MAC OS
I had the same problem on Mac OS(Mojave) and solved the problem as mentioned on this link - Openssl issue.
If you do not have Homebrew or don't know what is Homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Or if you already have Homebrew installed:
brew update && brew upgrade
brew uninstall --ignore-dependencies openssl; brew install https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb
Update:
Keep in mind, that I had to use --ignore-dependencies flag, because other packages installed that depend on OpenSSL.
Additional if the problem is caused after using pyenv, you can fix it by using:
brew reinstall python
For Debian users, the following may be of use:
sudo apt install libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev libtk8.6 libgdm-dev libdb4o-cil-dev libpcap-dev
Then cd to the folder with the Python 3.X library source code and run:
./configure
make
make install
I'm using Windows 10 and installed Miniconda 3 with Python 3.7.
I solved this error by following this https://github.com/conda/conda/issues/8273
Specifically, I copied the following files from C:\Users\MyUser\Miniconda3\Library\bin to C:\Users\MyUser\Miniconda3\DLLs:
libcrypto-1_1-x64.dll
libcrypto-1_1-x64.pdb
libssl-1_1-x64.dll
libssl-1_1-x64.pdb
For centos 7:
Install openssl:
sudo yum install openssl-devel
now goto python directory were we extracted the python tar,
run below commands
sudo ./configure
sudo make
sudo make install
This will fix the problem in centos...
For future Oracle Linux users trying to solve this, below is what worked for me.
First install missing libs:
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel
readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
Then cd to your Python3.X library and run:
make
make install
macOS, pyenv
In case of your python being an pyenv installed one, where pyenv is installed with homebrew on macOS, there might me a newer version available which fixes this:
$ brew update && brew upgrade pyenv
Then reinstalling the python version:
$ pyenv install 3.7.2
pyenv: /Users/luckydonald/.pyenv/versions/3.7.2 already exists
continue with installation? (y/N)
Note, it is a bit dirty to overwrite the existing python install like that, but in my case it did work out. Probably cleaner to delete it and then recreate it properly.
For Windows 10,windows 7
If pip install is not working on CMD prompt, run it using Anaconda prompt - it works.
https://github.com/pypa/virtualenv/issues/1139
Worked for me.
sudo apt-get install libssl-dev
Use this to enable ssl for pip.
Let me know if someone encounters issues.
Encountered this issue while installing python 3.8 from source on ubuntu. The steps needed to install it successfully alongside the default python 3.7 are summarised below :
sudo apt -y install libssl-dev zlib1g-dev build-essential
wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz
tar -xf Python-3.8.0.tgz
cd Python-3.8.0/
./configure --enable-optimizations
make
sudo make altinstall
The install instruction for zlib1g-dev and build-essential is redundant, as ubuntu desktop already has these, but was necessary for some of Amazon's EC2 instances. python 3.8.0 is the current release just now, but should be replaced with the latest available.
These instructions are best for keeping python 3.7 as the default for python3, and running python 3.8 in a virtual environment.
Similar to the above solution reinstall the python version with pyenv.
Somehow, I upgraded my openssl which broke the pyenv version python.
pyenv install 3.6.8
python-build: use openssl#1.1 from homebrew
python-build: use readline from homebrew
...
The first line says it relies on the homebrew openssl.
In my case, I reinstalled Python. It solved the problem.
brew reinstall python
For OpenSUSE in the same manner, but a few changes of listed above packages:
zypper install zlib-devel libopenssl-devel ncurses-devel sqlite3-devel readline-devel tk-devel gdbm-devel libpcap-devel xz-devel
Then cd to Python sources dir and
make
make install
or
make
make altinstall
And perhaps
ln -s /usr/local/lib64/python3.6/lib-dynload/ /usr/local/lib/python3.6/lib-dynload
should be executed for OpenSUSE users. See Python 3.7 install not working on openSUSE Leap 42.3
Just try installing through Anaconda prompt
I ran into this issue with Visual Studio Code installing pylint from the VS Code prompt.
I was able to overcome the issue by opening the Anaconda installation directory and running
pip install pylint
Then VS Code was happy, but that did not fix the issue as running
& C:/Users/happy/Anaconda3/python.exe -m pip install -U pylint
pretty much gave the same error so it seems that VS Code is unable to access the python modules.
Note that VS Code picks up the first python env it see when installed, the bottom left of the screen indicates which env is being used. Clicking on that area allows to set the environment. So even if you ran the pip install for an environment VS Code could be looking at a different one.
Best approach was to make sure that VS code had the correct python environment selected and that same environment is in the system PATH (under System Properties --> Advanced --> Environmental Variables)
Under the Path Variable, Edit and browse to the specific Anaconda directory that you want VSCode to use and add to PATH, I needed to Add the following:
C:\Users\happy\Anaconda3\
C:\Users\happy\Anaconda3\Scripts\
C:\Users\happy\Anaconda3\Library\bin\
C:\Users\happy\Anaconda3\Library\mingw-w64\bin\
Your Anaconda installation directory may differ.
One note is that Windows does not have the PATH variable take effect until you restart the terminal. In this case close and re-op VS code. If using a Terminal or PS Shell then close and reopen and check Path to make sure it is included.
The problem probably comes from your installed openssl package version. That was the case for me and I fixed this issue just upgrading it. I'm on Mac OS, using brew :
brew upgrade openssl
If you installed python with brew, this should directly fix the issue with it, as python is dependent on openssl
Newest Python 3.8.4 or higher should able to support https protocol out of box. If you still have old python installation on your pc - either download & install python3 manually, or using Chocolatey:
If you don't have Chocolatey, install it - from here: https://chocolatey.org/docs/installation
You can just copy paste one command line liner and execute it from command prompt with elevated priviledges.
choco install python3
if you don't have python3 installed, or you you have it installed - then:
choco upgrade python3
Notice also that you can use also anaconda distribution, as it has built-in python with https support, but this rather ancient instructions, no need to follow them anymore.
Install anaconda, using command line:
choco install anaconda3
Set environment variables:
set PATH=C:\tools\Anaconda3\Scripts;C:\tools\Anaconda3;C:\tools\Anaconda3\Library\bin;%PATH%
and then run command which failed. In my case it was:
pip install conan
Anaconda uses separate python installation, and pip is also anaconda specific.
As Tokci said, it also works for Windows 7.
"Go with the mouse to the Windows Icon (lower left) and start typing "Anaconda". There should show up some matching entries. Select "Anaconda Prompt". A new command window, named "Anaconda Prompt" will open."
Then pip works.
The following also helped to import xgboost:
https://www.youtube.com/watch?v=05djBSOs1FA
If someone is using Arch Linux OS, I solved the TLS/SSL problem by running this:
sudo pacman -S openssl
Then I could use pip to install the package I needed:
pip install openpyxl
Go to Anaconda prompt and type (if you have python 3.x installed on your engine) :
py -m pip install pymysql
i was having the same issue and this solved my problem. later after doing this you can import pymysql in power shell or any other prompt.
The issue is due to OpenSSL package is missing on your PC.
If pip install openpyxl also gives error.
you can fix this by installing OpenSSL(Win64 OpenSSL v1.1.1g) from below site :
slproweb.com/products/Win32OpenSSL.html
Restart the IDE you are using, for changes to be in effect.
In Windows 10 SQL Server 19 the solution is known.
Copy the following files:
libssl-1_1-x64.dll
libcrypto-1_1-x64.dll
from the folder
C:\Program Files\Microsoft SQL Server\MSSSQL15.MSSQLSERVER\PYTHON_SERVICES\Library\bin
to the folder
C:\Program Files\Microsoft SQL Server\MSSSQL15.MSSQLSERVER\PYTHON_SERVICES\DLLs
Then open a new DOS command shell prompt.
From https://learn.microsoft.com/en-us/sql/machine-learning/troubleshooting/known-issues-for-sql-server-machine-learning-services?view=sql-server-ver15#7-unable-to-install-python-packages-using-pip-after-installing-sql-server-2019-on-windows
Worked for me.
pkg install openssl
Use this to enable ssl.
Currently there is same issue in Anaconda prompt (Anaconda3) on Windows 10. Here is workaround: https://github.com/ContinuumIO/anaconda-issues/issues/10576
Fixed this without having to change anything related to TSL/SSL.
I was trying to see if the same thing was happening to pip, and saw that pip was broken. Did some digging and realized it's probably caused by Homebrew deleted python#2 on February 1st, 2020.
Running brew uninstall python#2 to delete python2 installed by Homebrew.
Destroyed the virtual env created using python3 and created a new one. pip3 installing works fine again.
I am on macOS and I had used brew but what Vaulstein mentioned in his answer didn't cover my case.
I run the following commands to make sure my current python was not installed by brew
brew list | grep python
python
python#2
brew info python
python#3.8: stable 3.8.3 (bottled)
Interpreted, interactive, object-oriented programming language
https://www.python.org/
Not installed
...
So I download the latest 3.8.5 from https://www.python.org/ and when installing it I saw following information
Certificate verification and OpenSSL
This package includes its own private copy of OpenSSL 1.1.1. The
trust certificates in system and user keychains managed by the
Keychain Access application and the security command line utility are not used as defaults by the Python ssl module
After installed 3.8.5 it fixed the problem.
I got into this problem using Ubuntu, pyenv and Python 3.8.1 managed by pyenv. There was actually no way to get pip to work correctly, since every time I tried to install anything, including pip itself, the same error showed up.
Final solution was to install, via pyenv, a newer version, in this case 3.8.6. Apparently, from 3.8.4 Python is prepared to run SSL/TLS out of the box, so everything worked fine.
I simply solved the problem with following command:
brew upgrade python#3.9
SSL is included by default on this version!
In my case I was running into issues with my $PATH on Linux. This can also happen on MacOS.
Check to see if /usr/bin/pip3 install package_name_goes_here works for you. If so then run
which pip3 this will tell you which is the first directory that pip3 is installed in.
If it is something like /usr/local/bin/pip3 which is different from /usr/bin/pip3 then you may need to adjust your $PATH.
Run
echo $PATH and copy the result.
The PATH is simply a colon separated list of directories that contain directories. Bash will always return the first instance of the program that you are attempting to execute. Move all the system directories upfront. Here is a list of some of the system directories:
/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
If that fails then verify you have openssl installed by running openssl version -a if not then install openssl.
If you've installed anaconda via scoop, and encounter this error while using pip from within a conda environment you can resolve it by...
Adding these to your path
C:\Users\YOUR_USERNAME\scoop\apps\anaconda3\current
C:\Users\YOUR_USERNAME\scoop\apps\anaconda3\current\Scripts
C:\Users\YOUR_USERNAME\scoop\apps\anaconda3\current\Library
C:\Users\YOUR_USERNAME\scoop\apps\anaconda3\current\Library\bin
Installing openssl via scoop
scoop install openssl
And copying the following DLLs from ..\anaconda3\Library\bin to ..\anaconda3\DLLs
References:
https://stackoverflow.com/a/54897379
https://stackoverflow.com/a/60405693

How to get Python import working with dlib (using cmake and osx)

Sorry if this is basic but I'm trying to install dlib to use with python as mentioned in (http://blog.dlib.net/2014/04/dlib-187-released-make-your-own-object.html) "Make your own object detector in Python!".
I downloaded the install files, unzipped, and used cmake as in the install instructions (http://dlib.net/compile.html)
cd examples
mkdir build
cd build
cmake ..
cmake --build . --config Release
which seemed to work fine
However typing "import dlib" in Python just gives ImportError: No module named dlib.
Any idea how I tell Python how to find / use the thing?
Just a note for reference that the easiest way to install is now to use:
sudo python setup.py install
Instead of manual file editing, you can pass -DPYTHON_LIBRARY:FILEPATH=/path/to/your/libpython2.7.dylib to cmake.
What ./compile_dlib_python_module.bat does is
mkdir build
cd build
cmake ../../tools/python
So, just run the commands by one by one and instead of
cmake ../../tools/python
run
cmake ../../tools/python -DPYTHON_LIBRARY:FILEPATH=/usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib
Dlib installation instructions for OSX (python3)
brew uninstall boost-python
brew uninstall boost
brew install boost-python --with-python3 --without-python
Installing default dlib
pip3 install dlib
Following Gives Some speedup
Installing dlib with AVX, SSE2, SSE4 instructions enabled (download the source code from dlib.net and execute from within the directory).
python setup.py install --yes USE_AVX_INSTRUCTIONS --yes USE_SSE2_INSTRUCTIONS --yes USE_SSE4_INSTRUCTIONS
On ubuntu I had to do the following:
sudo apt-get install libboost-python-dev cmake
cd to dlib-18.15/python_examples
Then:
./compile_dlib_python_module.bat
I then copied the dlib.so to dist-packages so it would be in my path.
sudo cp dlib.so /usr/local/lib/python2.7/dist-packages/
According to the documentation compile_dlib_python_module.bat will work on any os once you have both CMake and boost-python installed.
I finally got it to work! I'll be posting a detailed blog post about this later, but here's the gist for now. Basically, when I manually inspected the output of cmake, dlib was compiling and linking against the system version of Python not the Homebrew version of python.
If you're interested in the details, it appears that cmake was trying to compile and link against /usr/lib/libpython2.7.dylib. However, that is the system version of Python. It should be compiling a linking against /usr/local/Cellar/python/2.7.8/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib which is the Homebrew version of Python.
I manually edited CMakeFiles/dlib_.dir/build.make and /CMakeFiles/dlib_.dir/link.txt to point to the Homebrew dylib file instead of the system one. I was able to compile dlib and then run it without a segfault. And furthermore, I was able to run the object detectors without a problem.
You are compiling the C++ example programs. The python examples are in the python_examples folder. Also, each example has instructions at the top that tell you how to use it.
If you use Conda, it's much easier.
conda install -c menpo dlib
https://anaconda.org/menpo/dlib
for Python 3 support use:
python setup.py install --yes DPYTHON3
If you already compiled dlib source code from github by cmake command.
Then you want to run python program to call dlib api.
You should compile dlib Python API as below,
sudo python setup.py install
Or
sudo python setup.py install --yes USE_AVX_INSTRUCTIONS
if you have a CPU that supports AVX instructions, since this makes some things run faster. Note that you need to have boost-python installed to compile the Python API.(Linked from dlib README.md)
It works for me.
I encounted the same error with you.
When I looked at the folder "C:\Anaconda3\Lib\site-packages", I found "dlib-19.8.0-py3.4-win-amd64.egg\", it means I have compiled dlib successfully, but there is no "dlib\" folder under the "C:\Anaconda3\Lib\site-packages", it is inside "dlib-19.8.0-py3.4-win-amd64.egg\" folder, so the solution is simple: just copy the "dlib\" folder to path "C:\Anaconda3\Lib\site-packages", the Python interpreter will find the module and import it successfully.
Hope it will help!

Categories