Python modules not found in virtual python environment (linux)

1,721 views
Skip to first unread message

Petri

unread,
Aug 22, 2014, 6:36:32 AM8/22/14
to robotframe...@googlegroups.com
I am working in multi-user Redhat environment. Default python version there is 2.6.6 and I need to use python 2.7, so I installed virtual python environment to my home folder.
I also installed robotframework in my /home/petri/myVirtulPythonEnv.
pybot --version -->
Robot Framework 2.8.5 (Python 2.7.4 on linux2)

When I try to run tests I get errors like:
Suite setup failed:
TypeError: The basestring type cannot be instantiated

[ ERROR ] Reading XML source '/home/petri/workspace/test-automation/OPHV/output.xml' failed: ImportError: No module named expat

PYTHONPATH is set: /home/petri/myVirtulPythonEnv/bin/python

Tests in windows environment work well with python 2.7.3 and 2.7.4. Do you have any suggestion or idea what is wrong? Thanks for any help!

Ss Raghavan

unread,
Aug 24, 2014, 12:36:30 AM8/24/14
to robotframe...@googlegroups.com
I work on multi user Env. To avoid this problem, all the Env variables needs to be set locally to that user right from pythonpath, class path, and path,. This includes your python installation also. You need to add python, lib, site-packages folders to path variable. In your pythonpath variable you can map your custom python files and map that to path. It's done and ready now

Let's me know if didn't work

Gu Ru

unread,
Aug 25, 2014, 3:26:28 AM8/25/14
to robotframe...@googlegroups.com
Virtual env isolates well from natively installed  python package. however, now and then, there is always some dependency missing.

Well, all this hassle can be avoided, if we cud have rf as a part of anaconda python distribution (2.7+). python paths  are also well managed and installs in fraction of secs the needed dependency


the basic package provided by them is free

I have requested the community before. if we could somehow get rf into the list, most of the installation issues of rf on different os would disappear for sure

Cheers,

Gu Ru

unread,
Aug 25, 2014, 3:37:48 AM8/25/14
to robotframe...@googlegroups.com
more .., the installation of anaconda python distribution, provides "a kind" of virtual env and does not affect the native installation at all (thats already installed). one cud have any number of anaconda python distribution on different folder in the same os

Petri

unread,
Aug 25, 2014, 4:44:33 AM8/25/14
to robotframe...@googlegroups.com
Thanks for reply! Tried to put these folders to PATH: /home/petri/myVirtulPythonEnv/bin:/home/petri/myVirtulPythonEnv/lib/python2.7:
PYTHONPATH: /home/petri/myVirtulPythonEnv/lib/python2.7

Still getting same error: TypeError: The basestring type cannot be instantiated
Message has been deleted

Ed Manlove

unread,
Aug 25, 2014, 6:56:16 AM8/25/14
to robotframe...@googlegroups.com
Petri,

You mentioned in your original email that Python 2.6 was installed, you
needed 2.7 and thus you installed virtual environment locally. If I
recall correctly virtual environment can only create virtualenvs for
python version you have installed I am assuming you install Python 2.7
locally too? You might retry creating the virtually environment and I
would post the commands you used here. Maybe we might notice something,
like for example did you include the --no-site-packages argument when
creating the virtualenv?

Ed

Ss Raghavan

unread,
Aug 25, 2014, 7:06:16 AM8/25/14
to robotframe...@googlegroups.com
i see still site-packages are not added as part of the path. Try adding that and run your program again. it might help you problem resolved. The reason is that any python installations will be placed under site-packages, which needs to be inpath for execution.

Petri

unread,
Aug 25, 2014, 7:38:35 AM8/25/14
to robotframe...@googlegroups.com
Thank you everybody!

I tried also to put site-packages into PATH and many other options too, with no help. But now I have Anaconda installed and Robotframework is running!
Thank you Gu Ru.

Anyway, to Ed,  here are the steps I used to install virtual environment:
1.  curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py

Downloaded to the same directory as virtualenv.py (as "Wheel" packages = .whl) from:

2. python virtualenv.py ~/myVirtulPythonEnv
3. . ~/myVirtulPythonEnv/bin/activate
5. python distribute_setup.py
6. pip install robotframework-selenium2library
7. PATH verification and updating 

Reply all
Reply to author
Forward
0 new messages