简体   繁体   中英

PyDev project's PYTHONPATH automatically renamed. How do I properly configure this?

I'm new to PyDev and fairly rusty in Python. Trying to get back into it with a simple reddit app first. So here's my setup:

I have 2 PyDev projects: reddit and pylons (reddit api.py imports from pylons).

When I go into any file in the reddit project I get "unresolved import" for anything that tries to import from pylons. In reddit 's PYTHONPATH, I've tried adding /pylons and /pylons/pylons, but whenever I refresh the project, PyDev seems to rename my references to /reddit and /reddit/pylons.

How do I fix this? How do I properly add the pylons project into the PYTHONPATH of reddit ?

The most proper way to include another project source into your PYTHONPATH is to make a reference from your project to another project. For this make next steps:

  1. Choose your project in PyDev Package Explorer (usually tree-like panel on the left).
  2. Press Alt + Enter .
  3. Click Project References tab.
  4. Check Pylons project in a tab content frame.

Note , that path with source of both projects must be added to python path for Eclipse to build references for them.

Note #2 Also when you install some new Python packages you need to reindex them at Window > Preferences > PyDev > Interpreter - Python .

Since Rostyslav's solution is not working for you, perhaps you should try to add pylons as an external library. At reddit's Properties window click PyDev-PYTHONPATH tab and the External Libraries tab. Click Add source folder and find pylons's source folder. Changes to external libraries are not monitored. So you have to use Force restore internal info when pydev can't find new references (tipically when you make changes to pylons's structure).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM