I've been using python for a while but I can't remember how I used to install modules, I haven't needed to in forever. I recently reinstalled ubuntu so now I need to.
Firstly, I try to run setup.py and get this:
nicholas@nicholas-K53E:~$ python setup.py install
python: can't open file 'setup.py': [Errno 2] No such file or directory
I tried using synaptic to install BeautifulSoup but it didn't work either and python tells me there's no modules named that.
Some forums said that it had to do with being in the wrong working directory so I cd'd into my Python26 folder and tried to run python ./setup.py install from there and it still didn't work. I'm not sure what the deal is.
Any guidance?
asked Aug 23, 2012 at 0:19
2
sudo apt-get install python-setuptools
OR
sudo aptitude install python-setuptools
Then just run:
sudo easy_install
e.g.
sudo easy_install BeautifulSoup
answered Aug 23, 2012 at 0:36
DavidDavid
6,2792 gold badges24 silver badges21 bronze badges
sudo aptitude install python-beautifulsoup
should do that for you. Synaptic is alright, but I prefer aptitude for many reasons [CLI is one of them obviously]. Most of the modules you want should be available through your package manager, and beautifulsoup should definitely be. If that command does not work for you, there are other issues you need to look at.
You should definitely be
able to use easy_install for more popular packages and well, and as far as utilizing setup.py
you need to be in a directory actually containing it. What does ls | grep setup.py
return for you when you are in the proper working directory? setup.py
typically comes with a downloaded package, so make sure you are actually in the folder containing that package.
answered Aug 23, 2012 at 0:32
jaypbjaypb
1,50410 silver badges22 bronze badges
1
See other answers that recommend using the package manager that comes with Ubuntu [aptitude]. This is the easiest way to do it.
However, to answer your specific question, to install a package based on the Distutils you need to download the package, extract it, and then run the setup.py script.
As an example for BeautifulSoup:
Download the package from Beautiful Soup 4.1.3 [at time of writing get the beautifulsoup4-4.1.3.tar.gz tarball].
wget //www.crummy.com/software/BeautifulSoup/bs4/download/beautifulsoup4-4.1.3.tar.gz
tar xvfz beautifulsoup4-4.1.3.tar.gz
cd beautifulsoup4-4.1.3
sudo python setup.py install
answered Aug 23, 2012 at 0:42
mhawkemhawke
81.6k9 gold badges113 silver badges135 bronze badges
Sudo command will not work in Windows.
If you have something to install don't use Sudo, instead directly install your file:
for ex: If you sudo python3 setup.py install
then windows users can just type setup.py install
answered Jun 17, 2017 at 18:51
Are you using windows? if so, replace the python
with C:\python39\python.exe
and type in the rest of the command.
answered Aug 15, 2020 at 3:45
- What is your operating system and version?
Mac
Darwin Kernel Version 18.2.0: Thu Dec 20 20:46:53 PST 2018; root:xnu-4903.241.1~1/RELEASE_X86_64
- What is your Python version?
Python 3.6.8 :: Anaconda custom [64-bit]
- What version of pip do you have?
pip 18.0 from /Users/jonathan/anaconda3/lib/python3.6/site-packages/pip [python 3.6]
- Could you describe your issue in as much detail as possible?
I am trying to install a package locally using python setup.py install
. It seems to run setup.py
correctly, but when I import the module and run it using IPython or Jupyter, the version I just installed is not imported, an older version is imported.
The package can be found here:
//github.com/biblicalhumanities/greek-syntax
When I run python setup.py install
,
Here is the output from the command:
$ python: python setup.py install
options [after parsing config files]:
options [after parsing command line]:
option dict for 'aliases' command:
{}
option dict for 'install' command:
{}
running install
Distribution.get_command_obj[]: creating 'install' command object
config vars:
{'abiflags': 'm',
'base': '/Users/jonathan/anaconda3',
'dist_fullname': 'greeksyntax-0.1.dev0',
'dist_name': 'greeksyntax',
'dist_version': '0.1.dev0',
'exec_prefix': '/Users/jonathan/anaconda3',
'platbase': '/Users/jonathan/anaconda3',
'prefix': '/Users/jonathan/anaconda3',
'py_version': '3.6.8',
'py_version_nodot': '36',
'py_version_short': '3.6',
'sys_exec_prefix': '/Users/jonathan/anaconda3',
'sys_prefix': '/Users/jonathan/anaconda3',
'userbase': '/Users/jonathan/.local',
'usersite': '/Users/jonathan/.local/lib/python3.6/site-packages'}
Distribution.get_command_obj[]: creating 'build' command object
setting options for 'easy_install' command:
Distribution.get_command_obj[]: creating 'install_lib' command object
Distribution.get_command_obj[]: creating 'install_scripts' command object
running bdist_egg
Distribution.get_command_obj[]: creating 'bdist_egg' command object
Distribution.get_command_obj[]: creating 'egg_info' command object
Distribution.get_command_obj[]: creating 'bdist' command object
running egg_info
writing greeksyntax.egg-info/PKG-INFO
writing dependency_links to greeksyntax.egg-info/dependency_links.txt
writing requirements to greeksyntax.egg-info/requires.txt
writing top-level names to greeksyntax.egg-info/top_level.txt
Distribution.get_command_obj[]: creating 'build_py' command object
reading manifest file 'greeksyntax.egg-info/SOURCES.txt'
exclude_pattern: applying regex r'[^|\/][RCS|CVS|\.svn]\/'
writing manifest file 'greeksyntax.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.7-x86_64/egg
setting options for 'install_lib' command:
running install_lib
running build_py
creating build/bdist.macosx-10.7-x86_64/egg
creating build/bdist.macosx-10.7-x86_64/egg/greeksyntax
copying build/lib/greeksyntax/treedown.css -> build/bdist.macosx-10.7-x86_64/egg/greeksyntax
copying build/lib/greeksyntax/lowfat.py -> build/bdist.macosx-10.7-x86_64/egg/greeksyntax
copying build/lib/greeksyntax/rules.css -> build/bdist.macosx-10.7-x86_64/egg/greeksyntax
copying build/lib/greeksyntax/boxwood.css -> build/bdist.macosx-10.7-x86_64/egg/greeksyntax
copying build/lib/greeksyntax/xml.py -> build/bdist.macosx-10.7-x86_64/egg/greeksyntax
copying build/lib/greeksyntax/__init__.py -> build/bdist.macosx-10.7-x86_64/egg/greeksyntax
copying build/lib/greeksyntax/#lowfat.py# -> build/bdist.macosx-10.7-x86_64/egg/greeksyntax
copying build/lib/greeksyntax/03-luke.xml -> build/bdist.macosx-10.7-x86_64/egg/greeksyntax
byte-compiling build/bdist.macosx-10.7-x86_64/egg/greeksyntax/lowfat.py to lowfat.cpython-36.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/greeksyntax/xml.py to xml.cpython-36.pyc
byte-compiling build/bdist.macosx-10.7-x86_64/egg/greeksyntax/__init__.py to __init__.cpython-36.pyc
creating build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying greeksyntax.egg-info/PKG-INFO -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying greeksyntax.egg-info/SOURCES.txt -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying greeksyntax.egg-info/dependency_links.txt -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying greeksyntax.egg-info/requires.txt -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
copying greeksyntax.egg-info/top_level.txt -> build/bdist.macosx-10.7-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist/greeksyntax-0.1.dev0-py3.6.egg' and adding 'build/bdist.macosx-10.7-x86_64/egg' to it
removing 'build/bdist.macosx-10.7-x86_64/egg' [and everything under it]
Processing greeksyntax-0.1.dev0-py3.6.egg
Removing /Users/jonathan/anaconda3/lib/python3.6/site-packages/greeksyntax-0.1.dev0-py3.6.egg
Copying greeksyntax-0.1.dev0-py3.6.egg to /Users/jonathan/anaconda3/lib/python3.6/site-packages
greeksyntax 0.1.dev0 is already the active version in easy-install.pth
Installed /Users/jonathan/anaconda3/lib/python3.6/site-packages/greeksyntax-0.1.dev0-py3.6.egg
Processing dependencies for greeksyntax==0.1.dev0
Searching for BaseXClient==8.4.4
Best match: BaseXClient 8.4.4
Adding BaseXClient 8.4.4 to easy-install.pth file
Installing sample script to /Users/jonathan/anaconda3/bin
Using /Users/jonathan/anaconda3/lib/python3.6/site-packages
Finished processing dependencies for greeksyntax==0.1.dev0