Error message in Command Prompt when installing module - python

This is my first attempt at installing an add in for Python. I have extracted the twitter module to a folder within my Python33 directory that I have called 'Plug ins'. I have then navigated to this in Command Prompt and entered the following code that I have found on the Python website:
python setup.py install
That produced an error that 'python' was not a recognised command. When i removed 'python'a nd just ran:
setup.py install
I got the error message:
Import error: No module named 'setuptools'
What am I doing wrong?
Thanks

You need to install setuptools:
https://pypi.python.org/pypi/setuptools#installing-and-using-setuptools
Basically,
for Linux:
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | python
for Windows 7:
download and execute this file.
for Windows 8, execute in PowerShell (as Admin):
(Invoke-WebRequest https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py).Content | python -

Related

"Failed to import the site module" when running pip --version

I am using mac OS X, but am running into some trouble when I try to download pip to my terminal. If I type: python --version, I get the message that I have python 3.7 downloaded. So I would assume that I also have pip. But when I type pip --version, this message comes up on my terminal:
Fatal Python error: initsite: Failed to import the site module
ModuleNotFoundError: No module named 'site'
I attempted to download pip because I thought this might be occurring because I did not have it downloaded in the first place, but the same error message occurred during the download.

fatal error: 'Python/Python.h' file not found while installing couchapp

I am trying to install couchapp from the terminal on macOs High Sierra.
I have python 2.7.10 installed (by default) and I run $ pip2 install couchapp according to the couchapp documentation.
This is the error I get:
src/watchdog_fsevents.c:22:10: fatal error: 'Python/Python.h' file not found
#include <Python/Python.h>
^~~~~~~~~~~~~~~~~
1 error generated.
error: command 'cc' failed with exit status 1
----------------------------------------
Failed building wheel for watchdog
Here is what I have when I do $ ls in /System/Library/Frameworks/Python.framework/
Examples
Modules
Python
Resources
Versions
module.map
What I have tried so far:
Check that Xcode CL Tools are already installed running $ xcode-select --install
Try to use pip3 instead of pip2 (I have installed python 3.6 with Homebrew), but I get the same error message.
Do you have any idea? I have read other posts but they did not solve my problem.
Thank you
Had a very similar problem on my High Sierra (10.13.5) setup with Xcode CLI tools installed; for me the Python.h was found in /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
(Some resources say the location can be found via find /usr/local/Cellar/ -name Python.h, however this seems not work if your python was not installed with brew.)
Add the location to your C include path, or at compile time as a flag by setting -I flag as such: -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7.
The part that tripped me up was the import statement should then look like: #include <Python.h> rather than #include <Python/Python.h> if your Python.h is directly in the python2.7 directory.
Hope that helps,

pip install pyscipopt on mac - scip.h file not found

Initial Question
I've installed scipopsuite by following these instructions: http://scip.zib.de/doc/html/MAKE.php#BRIEFINSTALL
Make tests - complete without error.
Then when I try pip install pyscipopt I get the following error.
src/pyscipopt/scip.c:467:10: fatal error: 'scip/scip.h' file not found
#include "scip/scip.h"
^
1 error generated.
error: command 'gcc' failed with exit status 1
Specs: Anaconda Python 2.7, latest OSX
Follow Up
In response to comments(#mattmilten), I've done the following.
(1) Installed the make file - When i tried to run the install it failed because the name of the O.darwin.x86_64.gnu.shared.opt folder was set to 'static' instead of shared. I changed that name and then the install completed but did have these warnings:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: lib/libscipopt-4.0.0.darwin.x86_64.gnu.opt.a(stkchk.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: lib/libscipopt-4.0.0.darwin.x86_64.gnu.opt.a(stkchk.o) has no symbols
When i try:
>>> import pyscipopt
, I now get the following error.
Any suggestions would be appreciated.
ImportError: dlopen(/Users/"local"/anaconda/lib/python2.7/site-packages/pyscipopt/scip.so, 2): Symbol not found: ___gmp_version
Referenced from: /Users/"local"/anaconda/lib/python2.7/site-packages/pyscipopt/scip.so
Expected in: flat namespace in /Users/"local"/anaconda/lib/python2.7/site-packages/pyscipopt/scip.so
I'm guessing these things are linked - thanks.
As explained in the PySCIPOpt INSTALL you need to tell Python where you installed the SCIP Opt Suite: export SCIPOPTDIR=<path_to_install_dir>
The setup.py looks for this environment variable so you need to set it before you run pip install pyscipopt
Edit:
You need to install the SCIP Opt Suite (this basically copies the compiled files to some directory) as also explained in the INSTALL file

Installing Python setup tools on Unix to run Tweepy Twitter client for Python

I am trying to run Tweepy client for Twitter on my Unix account. whenever i try to run setup for Tweepy using the command:
python setup.py
I get this error:
Traceback (most recent call last):
File "setup.py", line 3, in ?
from setuptools import setup, find_packages
ImportError: No module named setuptools
Now i searched on some forums and found i need to add setup tools file. The file i found
setuptools-0.6c11-py2.7.egg
I FTP - ed this file to my unix directory where i have Tweepy client directory and my program which is using Tweepy.
Now, whenever i try to install setup tools using the command
python setuptools-0.6c11-py2.7.egg
I get the error :
python setuptools-0.6c11-py2.7.egg
File "setuptools-0.6c11-py2.7.egg", line 2
if [ `basename $0` = "setuptools-0.6c11-py2.7.egg" ]
^
SyntaxError: invalid syntax
Any clues/suggestions what i must be doing wrong here ?
Don't use setuptools, use distribute. Setuptools is old and deprecated. Until python 3.4 with packaging/distutils2 is around use distribute, which is a fork of old setuptools/distutils.
Simply download the distribute source tarball, unpack and run python setup.py install. Alternatively, you can download distribute-setup.py and just run it.
To install tweepy, run inside a virtualenv:
(venv) $ pip install tweepy
To create a virtual environment and install setuptools/distribute/easy_install, pip, and virtualenv, run:
$ curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py
$ python virtualenv.py venv
$ source ./venv/bin/activate
taken from here
The setuptools documentation suggest using sh setuptools-0.6c11-py2.7.egg instead of python setuptools-0.6c11-py2.7.egg.
You get a SyntaxError from python because setuptools-0.6c11-py2.7.egg begins as a shell script:
#!/bin/sh
if [ `basename $0` = "setuptools-0.6c11-py2.7.egg" ]
then exec python2.7 -c "import sys, os; sys.path.insert(0, os.path.abspath('$0')); from setuptools.command.easy_install import bootstrap; sys.exit(bootstrap())" "$#"
else
echo $0 is not the correct name for this egg file.
echo Please rename it back to setuptools-0.6c11-py2.7.egg and try again.
exec false
fi
PK\00\00\00\00F\A3\E...

Creating a new virtualenv results in an error

I'm trying to get virtualenv to work on my machine. I'm using python2.6, and after installing pip, and using pip to install virtualenv, running "virtualenv --no-site-packages cyclesg" results in the following:
New python executable in cyclesg/bin/python
Installing setuptools....
Complete output from command /home/nubela/Workspace/cyclesg...ython -c "#!python
\"\"\"Bootstrap setuptoo...
" /usr/lib/python2.6/site-packag...6.egg:
error: invalid Python installation: unable to open /home/nubela/Workspace/cyclesg_dep/cyclesg/include/multiarch-i386-linux/python2.6/pyconfig.h (No such file or directory)
----------------------------------------
...Installing setuptools...done.
New python executable in cyclesg/bin/python
Installing setuptools....
Complete output from command /home/nubela/Workspace/cyclesg...ython -c "#!python
\"\"\"Bootstrap setuptoo...
" /usr/lib/python2.6/site-packag...6.egg:
error: invalid Python installation: unable to open /home/nubela/Workspace/cyclesg_dep/cyclesg/include/multiarch-i386-linux/python2.6/pyconfig.h (No such file or directory)
----------------------------------------
...Installing setuptools...done.
Any idea how I can remedy this? Thanks!
Are you on mandriva?
In order to support multilib (mixing x86/x86_64) Mandriva messes up your python installation. They patched python, which breaks virtualenv; instead of fixing python, they then proceeded to patch virtualenv. This is useless if you are using your own virtualenv installed from pip.
Here is the bug: https://qa.mandriva.com/show_bug.cgi?id=42808
Are you on a linux based system? It looks like virtualenv is trying to build a new python exectable but can't find the files to do that. Try installing the python-dev package.

Categories

Resources