I have created a virtualenv and installed SQLAlchemy in it:
$ virtualenv alchemy
$ source alchemy/bin/activate
$ pip install sqlalchemy
import
works in python:
$ python
Python 2.7.5 (default, Mar 9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlalchemy
>>> print sqlalchemy.__version__
0.9.7
But it does not work in bpython:
>>> import sqlalchemy
Traceback (most recent call last):
File "<input>", line 1, in <module>
ImportError: No module named sqlalchemy
Why can't bpython find the package installed in the virtualenv, even though it is executed after source alchemy/bin/activate
is called?
In "Program/script" textbox you set the path to Python executable (in my case is inside the virtualenv folder). "Add arguments" => Just the name of your Python script (name. ppy). "Start in" => The full path of your Python script (without the name.py).
virtualenv is used to manage Python packages for different projects. Using virtualenv allows you to avoid installing Python packages globally which could break system tools or other projects. You can install virtualenv using pip.
These are almost completely interchangeable, the difference being that virtualenv supports older python versions and has a few more minor unique features, while venv is in the standard library.
bpython
must be installed in the virtualenv, otherwise the external, system-wide bpython is called:
$ source alchemy/bin/activate
(alchemy)[ 10:34PM ] [ adamatan@rubidium:/tmp ]
$ pip install bpython
...
$ alchemy/bin/bpython
--------------
>>> import sqlalchemy
>>> print sqlalchemy.__version__
0.9.7
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With