开发者

Importing Modules (SQLITE3) from Python Virtual Environment

开发者 https://www.devze.com 2023-01-08 23:01 出处:网络
I am using a Windows machine with python, django, and pinax installed. I can import modules from any normal location (even if it\'s not in the actuall installed directory).However, I cannot import th

I am using a Windows machine with python, django, and pinax installed.

I can import modules from any normal location (even if it's not in the actuall installed directory). However, I cannot import these same modules when I am in a virtual envi开发者_开发知识库ronment that I built for Pinax.

What are possible causes of this? What are possible solutions?


To diagnose failure to import, try using the -v switch to python:

python -v my_program.py

It will show its attempts to import your modules.


As the summary says,

[[virtualenv]] creates an environment that has its own installation directories, that doesn't share libraries with other virtualenv environments (and optionally doesn't use the globally installed libraries either).

Yet you appear surprised that the virtualenv you've built "doesn't share libraries"... why are you surprised, when that not-sharing is the whole point of virtualenv?!-)

Once you've made a python virtualenv.py ENV, to keep quoting from the summary I've already pointed you to, "if you use ENV/bin/easy_install the packages will be installed into the environment".

So, do that to install all packages you need to be available for importing in the virtual environment.

(Assuming you've used the --no-site-packages option to make the virtual environment, you need to do that also for all packages you had installed "site-wide", since the purpose of that option is to exclude them for better control and isolation).

0

精彩评论

暂无评论...
验证码 换一张
取 消