Questions tagged [pth]

18 questions
9
votes
3 answers

Script directory not included in sys.path when a ._pth is in use

I am attempting to solve a weird issue related to importing modules in a Python script I have written. The file that implements the module is in the same directory as the main Python script. The Python script works perfectly when I use ActivePython.…
Benilda Key
  • 2,836
  • 1
  • 22
  • 34
8
votes
3 answers

How to execute Python Code on Interpreter Startup in Virtualenv?

I want to execute code after the python interpreter has started. We use virtualenv and up to now we had a file called sitecustomize.py which got executed during interpreter start up. The sitecustomize.py was part of our project. We use the Django…
guettli
  • 25,042
  • 81
  • 346
  • 663
5
votes
1 answer

Python Packaging with .pth files

I have a suite of packages that are developed together and bundled into one distribution package. For sake of argument, let's assume I have Good Reasons for organizing my python distribution package in the following…
Ryan de Kleer
  • 1,246
  • 14
  • 24
4
votes
0 answers

.pth file not working in Python 3.5

I'm using Python 3.5 on Ubuntu 16.04 LTS. I save my python files in /home/me/Python and I would like to use a .pth-file to make python search that directory, so I created custompaths.pth and entered /home/me/Python on line 1. I've tried saving…
vikalm
  • 41
  • 3
3
votes
1 answer

Trying use a .pth file to add a path in documents folder on Mac

Hi everyone I'm trying to get Python configured on an OS X laptop and I'm having some trouble. I'm both new to Python and am very unfamiliar with the UNIX terminal. What I'd like to be able to do is to have a directory in my documents folder that…
Ben Williams
  • 745
  • 1
  • 5
  • 9
2
votes
1 answer

How to load an ONNX file and use it to make a ML prediction in PyTorch?

Below is the source code, I use to load a .pth file and do a multi-class image classification prediction. model = Classifier() # The Model Class. model.load_state_dict(torch.load('.pth')) model = model.to(device) model.eval() #…
Hari Krishnan U
  • 166
  • 5
  • 16
2
votes
1 answer

Mac OS X error: directory that is not on PYTHONPATH and which Python does not read ".pth" files from

I'm getting an error while trying to install FEnicS on Mac OS X 10.11.6. I've read the responses to similar questions on this website, and have tried the suggested solutions, but I must be doing something wrong. On running the command: curl -s…
sophia
  • 31
  • 6
2
votes
0 answers

Decrease clang parse/reparse time with chained precompiled headers?

I'm working on text editor (almost IDE) and i'm using llvm/clang behind the scenes (tokenizing, diagnostics). Almost every file that is edited includes main header file which includes some headers too which include some other headers (tree of…
4ntoine
  • 19,816
  • 21
  • 96
  • 220
2
votes
1 answer

How to increase clang parsing performance using PCH or PTH?

I'm using Clang C API for parsing and getting diagnostics. I've noticed that i'm using the same bundle of headers all the time, so i've decided to try to use PCH or PTH to increase performance. But i'm getting diagnostics that neither PCH nor PTH…
4ntoine
  • 19,816
  • 21
  • 96
  • 220
1
vote
0 answers

PyTorch - (Deployment model) convert from .pth to onnx

I want to convert my pyTorch model(.pth) to ONNX. This is my code. import torch import torchvision dummy_input = torch.randn(1,3,224,224,device = "cuda") model =…
frye
  • 11
  • 1
1
vote
1 answer

Add package path to python .pth file using environment variables

Is it possible to use environment variables to specify a library path in python .pth files and if yes, how so? Background: My python project (lives in /path/to/my/project) runs in a virtualenv, but needs to use an external (but local) package. Using…
fatoche
  • 31
  • 8
0
votes
0 answers

_pickle.UnpicklingError: A load persistent id instruction was encountered, but no persistent_load function was specified

when i wanna convert pkl model to pth model I receive an error and don’t know how to solve it. here is my code: import pickle import sys from enum import Enum from pathlib import Path from typing import Optional import torch checkpoint_path =…
0
votes
0 answers

how to run YOLO NAS onnx weight file (custom.onnx)

In YOLO NAS i convert best.pth to custom.onnx but it can't execute the output import torch from super_gradients.training import models from super_gradients.common.object_names import Models model = models.get('yolo_nas_s', num_classes =…
0
votes
1 answer

TEST FAILED: /home/mona/.local/lib/python3.8/site-packages/ does NOT support .pth files error: bad install directory or PYTHONPATH

I am using Python Virtual Environment for installing a package from Git Repo. When I use its setup.py file, I get the following error. How should I fix it? mona@goku:~/research/code/IP-Net/src/lib/models/networks/py_utils/_cpools$ python setup.py…
Mona Jalal
  • 34,860
  • 64
  • 239
  • 408
0
votes
2 answers

pth file is not processed

I was trying to add some folders to my path, so I added a .pth file to my site-packages folder. When it didn't work (I printed sys.path and it doesn't contain any of the paths I wrote in the file) , I tried to find the .pth file from within python…
T.G.
  • 743
  • 3
  • 6
  • 27
1
2