Re: path error

Robin Becker <[email protected]>
Newsgroups gmane.comp.python.reportlab.user
Message-ID <[email protected]>
OK can you try the following commands

c:\python34\python.exe -c"import sys;print(sys.exec_prefix)"

on my system this gives

c:\python44


c:\python34\python.exe -c"import reportlab;print(reportlab.__file__)"

on my system I see

c:\code\reportlab\__init__.py

because I have reportlab installed specially for development. If your 
python/reportlab is correctly installed you should see something related to

C:\Python34\Lib\site-packages. If reportlab is not installed properly you won't.

I tried the experiments that were suggested by Adrian's suggestions in a virtual 
environment.

EG

> C:\code>\python34\python.exe -mvenv tempenv
>
> C:\code>tempenv\Scripts\activate.bat
> (tempenv) C:\code>cd tempenv
>
> (tempenv) C:\code\tempenv>python -c"import reportlab.pdfgen"
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
> ImportError: No module named 'reportlab'
>
> (tempenv) C:\code\tempenv>touch reportlab.py
>
> (tempenv) C:\code\tempenv>python -c"import reportlab.pdfgen"
> Traceback (most recent call last):
>   File "<frozen importlib._bootstrap>", line 2195, in _find_and_load_unlocked
> AttributeError: 'module' object has no attribute '__path__'
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
> ImportError: No module named 'reportlab.pdfgen'; 'reportlab' is not a package

so if reportlab is completely absent the message is
 > Traceback (most recent call last):
 >   File "<string>", line 1, in <module>
 > ImportError: No module named 'reportlab'

if there is some other module on the PYTHONPATH casued by my touch reportlab.py 
then you get the message you have been seeing eg

 > (tempenv) C:\code\tempenv>python -c"import reportlab.pdfgen"
 > Traceback (most recent call last):
 >   File "<frozen importlib._bootstrap>", line 2195, in _find_and_load_unlocked
 > AttributeError: 'module' object has no attribute '__path__'
 >
 > During handling of the above exception, another exception occurred:
 >
 > Traceback (most recent call last):
 >   File "<string>", line 1, in <module>
 > ImportError: No module named 'reportlab.pdfgen'; 'reportlab' is not a package

however, even though it's not the right module/package you can still find out 
where it is using the __file__ attribute eg

> (tempenv) C:\code\tempenv>python -c"import reportlab;print(reportlab.__file__)"
> C:\code\tempenv\reportlab.py

so perhaps the second command I asked you to try above may help.


On 11/08/2014 16:09, Jose M.Allegue wrote:
> First of all  would like to thanks for your interest. I know that It isn´t
> you matter, but you are helping me.
>
> Well.
> I included   'C:\Python34\Lib\site-packages' in the enviroment path of
> windows, but nothing happens
> I unnistall reportlab and install again using     pip install reportlab.
> pip list>>>> there is reportalb packge installed ( and I can see that in
> Lib/site-packages) but....nothing fixed
>
> well
> 1) AttributeError: 'module' object has no attribute '__path__'
> Python is finding a module, just one without '__path__'
>
> 2) ImportError: No module named 'reportlab.pdfgen'; 'reportlab' is not a
> package
> Again 'reportlab' is being found, it is just not a package so you cannot
> get at pdfgen.
> How can I fix them ? How can I make a script importing canvas ?
>
> Thanks
......

-- 
Robin Becker
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.