How can I install a python .egg file - python

I am trying to install twisted on python 2.6 and it seems that the Zop interface is missing.
Also it seems that it is a .egg file. I downloaded this .egg file, now how can I install it?

Install virtualenv, which includes pip. Then you can simply run:
pip install twisted
pip will handle installing the zope.interface.
Instructions for installing virtualenv and pip on OS X
This is how I installed virtualenv and pip on OS X:
curl -O http://peak.telecommunity.com/dist/ez_setup.py
sudo python ez_setup.py
sudo easy_install pip
sudo pip install virtualenv
I also like to use virtualenvwrapper with virtualenv, so I installed it using:
sudo pip install virtualenvwrapper
Instructions for installing Twisted in a virtualenv
Now to create a new virtual environment and install Twisted, I simply issue:
mkvirtualenv twisted-env
pip install twisted

Related

I used pip3 to install virtualenv but I can't create venv and also I can't uninstall virtualenv

I'm using Linux Mint 20.2 with two directories / and /home.
I used the following command to install virtualenv:
>>> sudo pip3 install virtualenv
It worked fine and it installed in the following path:
>>> virtualenv --version
virtualenv 20.0.17 from /usr/lib/python3/dist-packages/virtualenv/__init__.py
But when I tried to create an environment I got the following error:
>>> python3 -m venv article
The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.
apt install python3.8-venv
You may need to use sudo with that command. After installing the python3-venv
package, recreate your virtual environment.
Failing command: ['/home/username/article_tools/article/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']
When I tried to uninstall it to install it using [b]sudo apt install python3.8-venv[/b], I got the following error:
>>> sudo pip3 uninstall virtualenv
Found existing installation: virtualenv 20.0.17
Not uninstalling virtualenv at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'virtualenv'. No files were found to uninstall.
How can I fix it? By fix, I mean installing virtualenv in a way that I don't get such errors.
The fundamental problem here seems to be that you are mixing up two different packages.
Python 3 comes with a built-in virtual environment module venv which is however not installed by default on Debian-based platforms. Like the error message says, apt-get install -y python3-venv will install this package, which you can then use with python3 -m venv.
virtualenv is a separate third-party package which you invoke with the command virtualenv. It's not a bad alternative, but if you are only just learning, I would suggest you simply ignore it for the time being.

Installing packages in python installed using home-brew

Hey everyone I installed Python3.9 on my Mac using homebrew package manager but now I do not know how to install packages to it for use
Can anyone please tell me, thanks !
You should first do some research on the Python virtual environment, but the final answer to your question is to use pip install for installing Python packages. Be aware that there are other options out there, but pip is the most prevalent.
When you installed python, it has pip installed by default. pip comes with python. You can check pip version by
pip --version
OR
pip3 --version
Now, in order to install any other package, you can install by
pip install <package-name>
It would be better if you install a virtual environment, and install all other packages inside the virtual environment so that you can install packages according to your project requirements and with different versions.
To install virtual environment, do
pip install virtualenv
Once the virtual environment is installed, you can create your virtualenv according to your project requirement by:
virtualenv -p python3 venv
Here venv is your virtualenv name. To activate it,
source venv/bin/actiavte
Now, you can install all your required packages inside this virtualenv by pip3 install <package-name>. This will keep it separated from your system environment.

osx install packages inside virtualenv

I tried to start virtualenv WITHOUT sudo but unfortunately it cannot find (Permission denied) /lib/python2.7/site-packages/easy_install.py. So I did:
sudo virtualenv name_env
The problem is that now pip is the global version (not inside pip):
which pip:
/usr/local/bin/pip
So I cannot install any package inside the environment.
If I start virtualenv without sudo:
virtualenv name_env
OSError: Command /Users/andrea/package_lambda/bin/python2.7 -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel failed with error code 2
Any suggestion?
Don't use sudo just because you can!
I suggest you install another Python environment using brew, and then install pip, and subsequently virtualenv. This way, you'll substantially correct the underlying problem.
I would follow this method:
brew install pyenv
pyenv install 2.7.11
Or check the available versions through:
pyenv versions
This way, you can install different versions and switch between them as you wish, for instance:
pyenv global 2.7.11
And then you can install pip like so:
python -m easy_intall pip
and then install virtualenv like so:
python -m pip install virtualenv
As pouria mentioned, I believe it's a good idea to make sure you installed virtualenv using pip in the first place. I also agree that on OSX, using sudo should be rare.
As mentioned on a previous answer, you should also check that the files in the bin of your virtual env are correct.
I found the solution myself. I was using iterm instead of terminal (standard mac OS X). Using terminal I did:
sudo pip uninstall virtualenv
sudo pip install virtualenv
sudo cp /usr/local/bin/virtualenv /bin/virtualenv
Then I can create start a virtualenv:
virtualenv name_env
source name_env/bin/activate
To install python package on it I use:
sudo pip install --target=name_env/lib/python2.7/site-packages/ package name
I have the following file ~/.pydistutils.cfg with the contents
[install]
prefix=
temporarily removing this file fixed the issue for me (i had this file in place to address a different issue)

Installing packages in Python3.4 by easy_install

I am having Anaconda3 and Python3.4. But when i run easy_install, packges get installed in Anaconda3\Lib\site-packages and I want to do it for C:\Python34\Lib\site-packages. How to do it?
Open Command prompt
Go to Python34/Scripts
cd C://Python34//Scripts
Install your packages using pip
pip install yourpackegeName

Errors in my Django install

I'm a beginner to Django so please excuse my ignorance here. I am trying to manually install Django so that I can start working with it. I've already installed Python successfully and downloaded Django to my Mac.
When I run the command "sudo python setup.py install" in the Django-1.5.1 directory, I get the following response:
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'setup.py': [Errno 2] No such file or directory
Can anyone help me understand why this isn't running correctly and what I can do to fix it?
Thanks,
Ryan
As Nathan said pip or easy_install is the best way to install packages. But you need to make sure you have pip installed first:
sudo easy_install pip
sudo pip install django
If you need to specify your version of Django you can do it this way:
sudo pip install django==1.5.1
But normally it's better not to install packages globally (with sudo) and instead it's better to use virtual environments:
sudo easy_install pip
sudo pip install virtualenv
sudo pip install virtualenvwrapper
source /usr/local/bin/virtualenvwrapper.sh
mkdir myproject
cd myproject
mkvirtualenv --no-site-packages myprojectenv
workon myprojectenv
pip install django
I would suggest installing it via pip:
sudo pip install django
or easy_install:
sudo easy_install install django
Both methods will use the Python cheeseshop to install the latest version of django.
Take a look at https://docs.djangoproject.com/en/dev/topics/install/#installing-an-official-release-with-pip for more details.

Categories

Resources