I use Mac (OS X 10.11.5). I want to install module pymssql for python.
In Terminal.app, I input sudo -H pip install pymssql, pip install pymssql, sudo pip install pymssql . But error occur.
The directory /Users/janghyunsoo/Library/Caches/pip/http or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory /Users/janghyunsoo/Library/Caches/pip or its parent directory is not owned by the current user and caching wheels has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pymssql
Downloading pymssql-2.1.2.tar.gz (898kB)
100% |████████████████████████████████| 901kB 955kB/s
Installing collected packages: pymssql
Running setup.py install for pymssql ... error
Complete output from command /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-KA5ksi/pymssql/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-A3wRBy-record/install-record.txt --single-version-externally-managed --compile:
setup.py: platform.system() => 'Darwin'
setup.py: platform.architecture() => ('64bit', '')
setup.py: platform.libc_ver() => ('', '')
setup.py: Detected Darwin/Mac OS X.
You can install FreeTDS with Homebrew or MacPorts, or by downloading
and compiling it yourself.
Homebrew (http://brew.sh/)
--------------------------
brew install freetds
MacPorts (http://www.macports.org/)
-----------------------------------
sudo port install freetds
setup.py: Not using bundled FreeTDS
setup.py: include_dirs = ['/usr/local/include', '/opt/local/include', '/opt/local/include/freetds']
setup.py: library_dirs = ['/usr/local/lib', '/opt/local/lib']
running install
running build
running build_ext
building '_mssql' extension
creating build
creating build/temp.macosx-10.6-intel-2.7
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include -I/opt/local/include -I/opt/local/include/freetds -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _mssql.c -o build/temp.macosx-10.6-intel-2.7/_mssql.o -DMSDBLIB
_mssql.c:18924:15: error: use of undeclared identifier 'DBVERSION_80'
__pyx_r = DBVERSION_80;
^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -u -c "import setuptools, tokenize;__file__='/private/tmp/pip-build-KA5ksi/pymssql/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-A3wRBy-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/tmp/pip-build-KA5ksi/pymssql/
The top voted solution did not work for me as brew did not link the older version of freetds on its own. I did this to solve the problem:
brew unlink freetds;
brew install freetds#0.91;
brew link --force freetds#0.91
I was able to work around this by reverting to an older version of FreeTDS through Homebrew before running the pip install.
brew unlink freetds; brew install homebrew/versions/freetds091
The solution was found by andrewmwhite at:
https://github.com/pymssql/pymssql/issues/432
Found Detailed and simple answer with step by step installation of pymssql on http://gree2.github.io/python/setup/2017/04/19/python-instal-pymssql-on-mac.
brew unlink freetds; brew install homebrew/core/freetds091
brew link --force freetds#0.91
pip install pymssql
Found a solution for pip/python2 & pip3/python3
Problem:
I was Unable to get a successful build from pip3 following #siva & #himanshu workaround works for python2 but not for python3.
pip3 install pymssql
..._mssql.c:21155:15: error: use of undeclared identifier 'DBVERSION_80'
__pyx_r = DBVERSION_80;
^
1 error generated.
error: command 'clang' failed with exit status 1
Your issue is not a permission issue, but, a code-compiling issue with dependent code for pymssql.
Here's the discussion,
Where I found the Solution on github.
It has been around for a while at this point, just placing here for visibility.
Just use the newest build of pymssql from gitub:
pip3 install git+https://github.com/pymssql/pymssql
Also works for python2
pip install git+https://github.com/pymssql/pymssql
OR
pip2 install git+https://github.com/pymssql/pymssql
I Tested on Mac OS X (10.13.6) & Homebrew (1.7.1-62-gddbefee) multiple times.
The command works for both versions of freetds (0.91) or (1.00.94)
"brew install homebrew/python/pymssql" also worked but will install older 2.1.1 as of today.
This worked for me on mac:
pip install cython
then
pip install git+https://github.com/pymssql/pymssql.git
All the solutions above work well . Just one word of caution , the setup.py for pymssql pip install pymssql expects that Homebrew has installed Freetds at /sw on your machine.
This was not the case in my machine so I had to use the work around here :
Manually download the .tar file for pymssql
Open setup.py
Edit the variable fink to add the path to where ever Freetds is actually installed on your machine.
if sys.platform == 'darwin':
fink = '<path to Freetds on your Machine>'
Then run python setup.py install
Related
The project was working perfectly until recently when I created a model for my database and tried to pip install requirement.txt. I have done everything I know including modifying my settings.py to add the missing library, reinstalling django and psycopg2, all to no avail. Here's my requirement.txt:
tweepy==3.8.0
django
gunicorn
django-heroku
The error i'm getting:
ld: library not found for -lssl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/Users/apple/Downloads/font_text/python-getting-started/getting-started/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/tn/843ff_ns4j5ddf0fyc998v6c0000gn/T/pip-install-phi9wroh/psycopg2/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/tn/843ff_ns4j5ddf0fyc998v6c0000gn/T/pip-record-sc3y24vo/install-record.txt --single-version-externally-managed --compile --install-headers /Users/apple/###/###/PROJECTFOLDER/getting-started/include/site/python3.7/psycopg2" failed with error code 1 in /private/var/folders/tn/843ff_ns4j5ddf0fyc998v6c0000gn/T/pip-install-phi9wroh/psycopg2/
Based on the error message, you need to install the openssl-devel package on your system.
After long hours of searching and experimenting, I finally was able to solve the problem. But I'm still investigating on what really could have caused the error. Anyways, here's what fixed it
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
pip install psycopg2
I found it here: error installing psycopg2, library not found for -lssl
You need to reinstall gcc , gcc-c++ and dependencies.
For python 2.7
$ sudo yum -y install gcc gcc-c++ kernel-devel
$ sudo yum -y install python-devel libxslt-devel libffi-devel openssl-devel
$ pip install "your python packet"
For python 3.4
$ sudo apt-get install python3-dev
$ pip install "your python packet"
Hope this will help.
I'm seeing this weird issue on ec2. I'm trying to install lsm-db package inside my virtualenv, it says it's successfully installed but when trying to import the package or do pip list it's not there.
I created this virtualenv by
virtualenv -p python3.6 venv
source venv/bin/activate
then running which python and which pip shows the correct ones inside venv as <path-to-my-project>/venv/bin/pip. Then I run pip install -r requirements.txt where sqlalchemy and lsm-db are included. A warning is shown
WARNING: Building wheel for lsm-db failed: [Errno 13] Permission denied: '/home/ec2-user/.cache/pip'
WARNING: Building wheel for sqlalchemy failed: [Errno 13] Permission denied: '/home/ec2-user/.cache/pip'
Failed to build lsm-db sqlalchemy
Installing collected packages: sqlalchemy, flask-sqlalchemy, lsm-db, MarkupSafe, click
Running setup.py install for sqlalchemy ... done
Running setup.py install for lsm-db ... done
Successfully installed MarkupSafe-1.1.1 click-7.0 flask-sqlalchemy-2.4.0 lsm-db-0.6.4 sqlalchemy-1.3.5
The last line shows they are correctly installed despite the warnings. However, they are not. Running pip install lsm-db gives
▶ pip install lsm-db
WARNING: The directory '/home/ec2-user/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/home/ec2-user/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting lsm-db
Downloading https://files.pythonhosted.org/packages/17/f2/dc68ecdece424eb206c42b8db924c5a7f6dd97d26df42a1c9fb41a6fe555/lsm-db-0.6.4.tar.gz (316kB)
|████████████████████████████████| 317kB 14.7MB/s
Building wheels for collected packages: lsm-db
WARNING: Building wheel for lsm-db failed: [Errno 13] Permission denied: '/home/ec2-user/.cache/pip'
Failed to build lsm-db
Installing collected packages: lsm-db
Running setup.py install for lsm-db ... done
Successfully installed lsm-db-0.6.4
Again it shows it's installed, but it's not. Not in pip list, can't import in Python. What is going on here? Why do I see permission issue inside virtualenv? I didn't create the virtualenv with sudo if that's a potential problem. Is it related to the way I installed virtualenv?
EDIT
I changed the permission and reinstall pip with sudo yum install python36-pip. Now I'm seeing this... sorry it seems like a new problem
Running setup.py install for lsm-db ... error
ERROR: Complete output from command /home/ec2-user/<project>/venv/bin/python3.6 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-bhhmd3j8/lsm-db/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-__gotpo6/install-record.txt --single-version-externally-managed --compile --install-headers /home/ec2-user/<project>/venv/include/site/python3.6/lsm-db:
ERROR: /tmp/pip-install-bhhmd3j8/lsm-db/setup.py:11: UserWarning: Cython not installed, using pre-generated C source file.
warnings.warn('Cython not installed, using pre-generated C source file.')
running install
running build
running build_ext
building 'lsm' extension
creating build
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/src
gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python3.6m -c lsm.c -o build/temp.linux-x86_64-3.6/lsm.o
lsm.c:32:20: fatal error: Python.h: No such file or directory
#include "Python.h"
^
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command "/home/ec2-user/<project>/venv/bin/python3.6 -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-bhhmd3j8/lsm-db/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-__gotpo6/install-record.txt --single-version-externally-managed --compile --install-headers /home/ec2-user/<project>/venv/include/site/python3.6/lsm-db" failed with error code 1 in /tmp/pip-install-bhhmd3j8/lsm-db/
EDIT
Thanks for the pointers, now I installed the python development package on ec2 and tried to install lsm-db again
> sudo yum install python36-devel
...
> pip install lsm-db
Collecting lsm-db
Using cached https://files.pythonhosted.org/packages/17/f2/dc68ecdece424eb206c42b8db924c5a7f6dd97d26df42a1c9fb41a6fe555/lsm-db-0.6.4.tar.gz
Building wheels for collected packages: lsm-db
Building wheel for lsm-db (setup.py) ... done
Stored in directory: /home/ec2-user/.cache/pip/wheels/ed/32/8a/b0f3aa15b68f1e6b8f2dcc6285de4796b6b58af71c5f280f48
Successfully built lsm-db
Installing collected packages: lsm-db
Successfully installed lsm-db-0.6.4
again, it shows it's successful, and which python gives me the right python in my venv. However, I have the exact same result as the beginning, pip list does not have lsm-db and I cannot import it in python.
This is entirely an issue on ec2, I can successfully use lsm-db in my virtualenv on my mac. There must be something off with virtualenv on ec2 here, why the right pip in venv cannot install a package in venv?? I'm completely lost. If anyone has experience please chime in!
(To work around this problem, I'm switching from lsm-db to sqlitedict in my code. sqlitedict can be installed no problem, so it narrows the suspect down to just lsm-db specific issues.)
This question from 2016 is more similar to mine but it has no conclusion why or any solution.
Pip says that pymongo has been installed, but doesn't show it as installed
Another potentially related question:
Amazon EC2 virtualenv: pip says it installed numpy but python can't find it
The problem seems to be with system file permissions. You can check the owner:group as well as rwx permissions for other users of the folder '/home/ec2-user/.cache/pip' from terminal using:
ls -lh /home/ec2-user/.cache/pip
In order to change the owner of the folder use command:
sudo chown -R ec2-user /home/ec2-user/.cache/pip
Another way to solve is to allow rwx permissions to all users by:
sudo chmod -R 777 /home/ec2-user/.cache/pip
I'm trying to install chatterbot on macOS with
python3 -m pip install chatterbot
and every time I get the same error during the step "Installing build dependencies ... /"
ERROR: Failed building wheel for spacy
Running setup.py clean for spacy
Failed to build spacy
ERROR: Could not build wheels for spacy which use PEP 517 and cannot be installed directly
Can someone please help?
Installing collected packages: spacy, chatterbot
Running setup.py install for spacy ... error
ERROR: Complete output from command /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/ry/sht50z853vn58nwg6wbzt4l00000gn/T/pip-install-33629q9f/spacy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/ry/sht50z853vn58nwg6wbzt4l00000gn/T/pip-record-z9jsui8q/install-record.txt --single-version-externally-managed --compile:
ERROR: running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.7
creating build/lib.macosx-10.9-x86_64-3.7/spacy
copying spacy/lemmatizer.py -> build/lib.macosx-10.9-x86_64-3.7/spacy
running build_ext
building 'spacy._align' extension
creating build/temp.macosx-10.9-x86_64-3.7
creating build/temp.macosx-10.9-x86_64-3.7/spacy
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I/private/var/folders/ry/sht50z853vn58nwg6wbzt4l00000gn/T/pip-install-33629q9f/spacy/include -I/Library/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c spacy/_align.cpp -o build/temp.macosx-10.9-x86_64-3.7/spacy/_align.o -O2 -Wno-strict-prototypes -Wno-unused-function -stdlib=libc++
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command "/Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -u -c 'import setuptools, tokenize;__file__='"'"'/private/var/folders/ry/sht50z853vn58nwg6wbzt4l00000gn/T/pip-install-33629q9f/spacy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/ry/sht50z853vn58nwg6wbzt4l00000gn/T/pip-record-z9jsui8q/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/ry/sht50z853vn58nwg6wbzt4l00000gn/T/pip-install-33629q9f/spacy/
You could try python3 -m pip install --no-binary spacy chatterbot, which should tell pip to not build the wheel
Alternately python3 -m pip install --no-use-pep517 chatterbot.
I had the same problem while installing kivy through command prompt.
If you use Pycharm then there is an easy way to avoid these problems.
Open Pycharm-->GoTo Files-->Settings-->Project-->Python Interpreter--> + sign-->then search for what you want to install. Check the version which works for you and install it.
If you get an error then try and install other versions of it. That would solve the issue.
Try installing the python-dev version.
For python3.7
sudo apt-get install python3.7-dev
For python3.6
sudo apt-get install python3.6-dev
In one of the scenarios where if you are using Anaconda, then you have to install using this command:
conda install -c conda-forge spacy, hope this helps !!
I had this issue with MacOS for a different package. I found this warning in the log:
WARNING: Building wheel for bottleneck failed: [Errno 13] Permission denied: '/Users/avi/Library/Caches/pip/wheels/87'
Then I gave my user access to the pip/wheels directory and then the installation worked.
Easy, try to run this:
pip install pep517
And then try to install again
python3 -m pip install chatterbot
I have PyAudio (0.2.7) installed in my system.
When I tried to upgrade using
sudo pip install pyaudio --upgrade
I'm getting this.
Downloading/unpacking pyaudio from https://pypi.python.org/packages/44/39/f3b9b16d32cc8588fa06bb2e813cea35363f5502117cd6cc7f619b556d9f/PyAudio-0.2.10.tar.gz#md5=b65354d997fa00a9166f8dbcb83075e6
Downloading PyAudio-0.2.10.tar.gz (287kB): 287kB downloaded
Running setup.py (path:/tmp/pip_build_root/pyaudio/setup.py) egg_info for package pyaudio
Installing collected packages: pyaudio
Found existing installation: PyAudio 0.2.7
Not uninstalling PyAudio at /usr/lib/python3/dist-packages, owned by OS
.......
.......
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.4m -c src/_portaudiomodule.c -o build/temp.linux-x86_64-3.4/src/_portaudiomodule.o
src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory
#include "portaudio.h"
^
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
----------------------------------------
Can't roll back PyAudio; was not uninstalled
Cleaning up...
Command /usr/bin/python3 -c "import setuptools, tokenize;__file__='/tmp/pip_build_root/pyaudio/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-ih3i9qsm-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_root/pyaudio
Storing debug log for failure in /home/jobin/.pip/pip.log
I'm using elementary os 14.04
What is the problem here?
Thanks #Cristian Ciupitu for the advice to install portaudio-dev.
But portaudio-dev did not installed with sudo apt-get install portaudio-dev in my case.
I got
E: Unable to locate package portaudio-dev
How this was solved
Downloaded the .tgz of portaudio file from here
Then Extract the downloaded file.
cd to the extracted folder.
Then ./configure && make
Now do sudo make install
Then upgrade pyaudio by sudo pip install pyaudio --upgrade
Now pyaudio was successfully installed.
run in terminal:
$ sudo apt install python3-pyaudio
This worked for me
sudo apt-get install portaudio19-dev python-pyaudio
then do this
pip install PyAudio
You need to install the portaudio-dev package, for example by running:
sudo apt-get install portaudio-dev
pip install pyaudio --upgrade
pip install pyaudio --user
When I Run Command pypy -m pip install cryptography
then I have got below Errors:
cc -arch x86_64 -O2 -fPIC -Wimplicit -I/opt/pypy-5.0.1/include -c build/temp.macosx-10.10-x86_64-2.7/_openssl.c -o build/temp.macosx-10.10-x86_64-2.7/build/temp.macosx-10.10-x86_64-2.7/_openssl.o
build/temp.macosx-10.10-x86_64-2.7/_openssl.c:423:10: fatal error: 'openssl/e_os2.h' file not found
#include
^
1 error generated.
error: command 'cc' failed with exit status 1
----------------------------------------
Command "/usr/local/bin/pypy -u -c "import setuptools, tokenize;file='/private/var/folders/_t/8l_tq9210xl4bzlhkspnv8br0000gn/T/pip-build-Gjhf5l/cryptography/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /var/folders/_t/8l_tq9210xl4bzlhkspnv8br0000gn/T/pip-6_y8I9-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/_t/8l_tq9210xl4bzlhkspnv8br0000gn/T/pip-build-Gjhf5l/cryptography/
On OS X PyPy you'll need to brew install openssl (or port install or whatever) and then run the following command:
LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include" pip install cryptography
If you use ports modify the paths to point at the proper location.
if you pc is mac,please configure as follows:
export LDFLAGS=-L/usr/local/opt/openssl/lib
export CPPFLAGS=-I/usr/local/opt/openssl/include
and amazingly,it works fine for me.
Cryptography requires compiling C Extensions.
Depending on the the platform you're on, you should install python-dev and gcc prior to installing cryptography:
debian: sudo apt-get install python-dev gcc
rhel: sudo yum install python-devel gcc
windows: you need to install the Python C++ Runtime (https://www.microsoft.com/en-us/download/details.aspx?id=44266)