Having trouble with setup.py

青春壹個敷衍的年華 提交于 2019-12-08 05:02:48

问题


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?


回答1:


sudo apt-get install python-setuptools

OR

sudo aptitude install python-setuptools

Then just run:

sudo easy_install <module>

e.g.

sudo easy_install BeautifulSoup



回答2:


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.




回答3:


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 http://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



回答4:


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



来源:https://stackoverflow.com/questions/12083158/having-trouble-with-setup-py

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!